Stream.h 945 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "mupdf/fitz.h"
  2. #include "mupdf/pdf.h"
  3. #include "MuPDF.h"
  4. #ifndef __STREAM
  5. #define __STREAM
  6. #pragma once
  7. using namespace System;
  8. using namespace System::Runtime::InteropServices;
  9. namespace MuPDF {
  10. /// <summary>
  11. /// Encapsulates the file stream used by MuPDF
  12. /// </summary>
  13. public ref class Stream sealed : IDisposable {
  14. public:
  15. Stream(array<Byte>^ data);
  16. Stream(String^ filePath);
  17. array<Byte>^ ReadAll(int maxSize);
  18. array<Byte>^ ReadAll() {
  19. return ReadAll(0x6400000);
  20. }
  21. Stream^ DecodeTiffFax(int width, int height, int k, bool endOfLine, bool encodeByteAlign, bool endOfBlock, bool blackIs1);
  22. internal:
  23. Stream(fz_stream* stream) : _stream(stream), _initDataLength(-1) {
  24. fz_keep_stream(Context::Ptr, stream);
  25. }
  26. ~Stream() {
  27. ReleaseHandle();
  28. }
  29. property fz_stream* Ptr {
  30. fz_stream* get() { return _stream; }
  31. }
  32. private:
  33. fz_stream* _stream;
  34. GCHandle _data;
  35. int _initDataLength;
  36. void ReleaseHandle();
  37. };
  38. };
  39. #endif