Ejemplo n.º 1
0
        public unsafe static Bitmap ConvertPixelByPixel(IntPtr ipd)
        {
            ThumbnailGenerator.DIBSECTION dIBSECTION = default(ThumbnailGenerator.DIBSECTION);
            ThumbnailGenerator.GetObjectDIBSection(ipd, Marshal.SizeOf(dIBSECTION), ref dIBSECTION);
            int    bmWidth  = dIBSECTION.dsBm.bmWidth;
            int    bmHeight = dIBSECTION.dsBm.bmHeight;
            Bitmap result;

            if (bmWidth <= 0 || bmHeight <= 0)
            {
                result = null;
            }
            else
            {
                FastBitmap fastBitmap = new FastBitmap(bmWidth, bmHeight);
                fastBitmap.LockBitmap();
                ThumbnailGenerator.RGBQUAD *ptr = (ThumbnailGenerator.RGBQUAD *)((void *)dIBSECTION.dsBm.bmBits);
                for (int i = 0; i < dIBSECTION.dsBmih.biWidth; i++)
                {
                    for (int j = 0; j < dIBSECTION.dsBmih.biHeight; j++)
                    {
                        int num = j * dIBSECTION.dsBmih.biWidth + i;
                        if (ptr[num].rgbReserved != 0)
                        {
                            fastBitmap.SetPixel(i, j, ptr[num].rgbReserved, ptr[num].rgbRed, ptr[num].rgbGreen, ptr[num].rgbBlue);
                        }
                    }
                }
                fastBitmap.UnlockBitmap();
                result = fastBitmap;
            }
            return(result);
        }
Ejemplo n.º 2
0
 public static extern int GetObjectDIBSection(IntPtr hObject, int nCount, ref ThumbnailGenerator.DIBSECTION lpObject);