Exemplo n.º 1
0
 public static unsafe int SetDIBitsToDevice(IntPtr hdc, int xDest, int yDest, uint
                                            dwWidth, uint dwHeight, int xSrc, int ySrc, uint uStartScan, uint cScanLines,
                                            byte[] lpvBits, ref BitmapInfoHeader bitmapInfoHeader, DibBmiColorUsageFlag fuColorUse)
 {
     fixed(BitmapInfoHeader *bitmapInfoHeaderPtr = &bitmapInfoHeader)
     {
         return(Gdi32Methods.SetDIBitsToDevice(hdc, xDest, yDest,
                                               dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, new IntPtr(bitmapInfoHeaderPtr),
                                               fuColorUse));
     }
 }
Exemplo n.º 2
0
 public static int SetDIBitsToDevice(IntPtr hdc, int xDest, int yDest, uint
                                     dwWidth, uint dwHeight, int xSrc, int ySrc, uint uStartScan, uint cScanLines,
                                     byte[] lpvBits, ref BitmapInfo bitmapInfo, DibBmiColorUsageFlag fuColorUse)
 {
     using (var pbmi = BitmapInfo.NativeAlloc(ref bitmapInfo))
     {
         return(Gdi32Methods.SetDIBitsToDevice(hdc, xDest, yDest,
                                               dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, pbmi.GetDangerousHandle(),
                                               fuColorUse));
     }
 }
Exemplo n.º 3
0
        public static unsafe int SetRgbBitsToDevice(IntPtr hdc, int width, int height, IntPtr pixelBufferPtr,
                                                    int xSrc = 0,
                                                    int ySrc = 0, int xDest = 0, int yDest = 0, bool isRgba = true, bool isImageTopDown = true)
        {
            var bi = new BitmapInfoHeader
            {
                Size            = (uint)Marshal.SizeOf <BitmapInfoHeader>(),
                Width           = width,
                Height          = isImageTopDown ? -height : height,
                CompressionMode = BitmapCompressionMode.BI_RGB,
                BitCount        = isRgba ? (ushort)32 : (ushort)24,
                Planes          = 1
            };

            return(Gdi32Methods.SetDIBitsToDevice(hdc, xDest, yDest, (uint)width, (uint)height, xSrc, ySrc, 0,
                                                  (uint)height, pixelBufferPtr, new IntPtr(&bi),
                                                  DibBmiColorUsageFlag.DIB_RGB_COLORS));
        }