Re: 8 bit image
- From: "Michael Phillips, Jr." <mphillips53@xxxxxxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 16:40:08 -0500
> How do I instantiate an RGBQUAD?
[StructLayout(LayoutKind.Sequential)]
public struct RGBQUAD
{
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved;
};
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFOHEADER
{
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
};
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFO
{
public BITMAPINFOHEADER bmiHeader;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst=1024)]
public RGBQUAD [] bmiColors;
};
// For 8bpp Image
BITMAPINFO bmi = new BITMAPINFO();
bmi.bmiHeader.biSize = (UInt32)Marshal.SizeOf(bmi.bmiHeader);
// you fill out the rest of the structure
....
// fill in the color palette, either read the colors from a file or create
them yourself
for ( int i = 0; i < 256; i++ )
{
bmi.bmiColors[i].rgbBlue = blue; // you supply the colors
bmi.bmiColors[i].rgbRed = red;
bmi.bmiColors[i].rgbGreen = green;
bmi.bmiColors[i].rgbReserved = 0;
}
....
// Create 8bpp DIB bitmap
IntPtr hBmp = CreateDIBSection(hDC, bmi, 0, ref pBits, IntPtr.Zero, 0);
I hope this helps!
.
- Follow-Ups:
- Re: 8 bit image
- From: grstefan
- Re: 8 bit image
- References:
- Re: 8 bit image
- From: Michael Phillips, Jr.
- Re: 8 bit image
- From: grstefan
- Re: 8 bit image
- Prev by Date: Re: 8 bit image
- Next by Date: Re: Bitmap to Clipboard problem
- Previous by thread: Re: 8 bit image
- Next by thread: Re: 8 bit image
- Index(es):
Relevant Pages
|
Loading