예제 #1
0
 PDFiumBitmap(FPDF_BITMAP bitmap, BitmapFormats format)
     : base(bitmap)
 {
     if (bitmap.IsNull)
     {
         throw new PDFiumException();
     }
     GetBytesPerPixel(format);
     Format = format;
 }
예제 #2
0
 static int GetBytesPerPixel(BitmapFormats format)
 {
     if (format == BitmapFormats.FPDFBitmap_BGR)
     {
         return(3);
     }
     if (format == BitmapFormats.FPDFBitmap_BGRA || format == BitmapFormats.FPDFBitmap_BGRx)
     {
         return(4);
     }
     if (format == BitmapFormats.FPDFBitmap_Gray)
     {
         return(1);
     }
     throw new ArgumentOutOfRangeException(nameof(format));
 }
예제 #3
0
        public FilmPlayer(
            string _fileName,
            Camera.FrameHandler _recData = null,
            BitmapFormats _format = BitmapFormats.Default,
            int _nLoopedFrames = 0)
            : base(_recData)
        {
            //Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            //if (dlg.ShowDialog() == true)
            //    filePath = dlg.FileName;

            if (!File.Exists(_fileName)) throw new FileNotFoundException("Файла с указанным именем не существует.");

            fs = File.OpenRead(_fileName);
            br = new BinaryReader(fs);

            format = _format;
            nLoopedFrames = _nLoopedFrames;

            Type FileHeaderType;
            Type InfoHeaderType;

            switch (format)
            {
                case BitmapFormats.Default:
                    FileHeaderType = typeof(BitmapFileHeader);
                    InfoHeaderType = typeof(BitmapInfoHeader);
                    break;
                case BitmapFormats.OLS:
                    FileHeaderType = typeof(OLSFileHeader);
                    InfoHeaderType = typeof(OLSInfoHeader);
                    break;
                default:
                    throw new NotImplementedException();
            }

            fileHeaderBuff = new byte[Marshal.SizeOf(FileHeaderType)];
            fileHeaderHandle = GCHandle.Alloc(fileHeaderBuff, GCHandleType.Pinned);
            fileHeader0 = fileHeaderHandle.AddrOfPinnedObject();

            infoHeaderBuff = new byte[Marshal.SizeOf(InfoHeaderType)];
            infoHeaderHandle = GCHandle.Alloc(infoHeaderBuff, GCHandleType.Pinned);
            infoHeader0 = infoHeaderHandle.AddrOfPinnedObject();
        }
예제 #4
0
 /// <summary>
 /// Creates a new <see cref="PDFiumBitmap"/> using memory allocated by the caller.
 /// The caller is responsible for freeing the memory and that the adress stays
 /// valid during the lifetime of the returned <see cref="PDFiumBitmap"/>.
 /// </summary>
 /// <param name="width">The width of the new bitmap.</param>
 /// <param name="height">The height of the new bitmap.</param>
 /// <param name="format">The format of the new bitmap.</param>
 /// <param name="scan0">The adress of the memory block which holds the pixel values.</param>
 /// <param name="stride">The number of bytes per image row.</param>
 public PDFiumBitmap(int width, int height, BitmapFormats format, IntPtr scan0, int stride)
     : this(PDFium.FPDFBitmap_CreateEx(width, height, format, scan0, stride), format)
 {
 }
예제 #5
0
 /// <summary>
 /// Creates a new <see cref="PdfiumBitmap"/> using memory allocated by the caller.
 /// The caller is responsible for freeing the memory and that the adress stays
 /// valid during the lifetime of the returned <see cref="PdfiumBitmap"/>. To free
 /// unmanaged resources, <see cref="Dispose"/> must be called.
 /// </summary>
 /// <param name="width">The width of the new bitmap.</param>
 /// <param name="height">The height of the new bitmap.</param>
 /// <param name="format">The format of the new bitmap.</param>
 /// <param name="scan0">The adress of the memory block which holds the pixel values.</param>
 /// <param name="stride">The number of bytes per image row.</param>
 public PdfiumBitmap(int width, int height, BitmapFormats format, IntPtr scan0, int stride)
     : this(Pdfium.FPDFBitmap_CreateEx(width, height, format, scan0, stride))
 {
     FillRectangle(0, 0, width, height, 0xFFFFFFFF);
 }