I load a bitmap file into my app now how do I relate the bytes in this file to the Type structures available? Like these...
I made a very simple bitmap and here is the byte code of that file but I do not know how the data in the code is related to any of the above Type structures.
Bitmap code:
The bitmap is 3 Pixels wide by 2 Pixels high, each pixel a different color. 6 pixels total
The RGB colors used are
FF 00 00 Red
00 FF FF Cyan
FF 00 FF Magenta
00 FF 80 Green like
FF FF 00 Yellow
FF 80 40 Orange like
From looking at the bitmap dump I see the colors and they appear to be in BGR order and from bottom row horizontally upward. I can also see the width and height in the dump but I don't know how to read the rest of the bytes or to which Type structure they apply to.
This thread is in relations to the other thread I started How To Find Color In A Bitmap and my first thought was to scan the picture in a picturebox pixel by pixel but then realized that could take a very log time and then it occured to me to use the bitmap code itself if I opened the bitmap file and read in the data.
Code:
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type RGBTRIPLE
rgbtBlue As Byte
rgbtGreen As Byte
rgbtRed As Byte
End Type
Private Type BITMAP '14 bytes
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Type BITMAPCOREHEADER '12 bytes
bcSize As Long
bcWidth As Integer
bcHeight As Integer
bcPlanes As Integer
bcBitCount As Integer
End Type
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type BITMAPCOREINFO
bmciHeader As BITMAPCOREHEADER
bmciColors As RGBTRIPLE
End Type
Private Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Type BITMAPV4HEADER
bV4Size As Long
bV4Width As Long
bV4Height As Long
bV4Planes As Integer
bV4BitCount As Integer
bV4V4Compression As Long
bV4SizeImage As Long
bV4XPelsPerMeter As Long
bV4YPelsPerMeter As Long
bV4ClrUsed As Long
bV4ClrImportant As Long
bV4RedMask As Long
bV4GreenMask As Long
bV4BlueMask As Long
bV4AlphaMask As Long
bV4CSType As Long
bV4Endpoints As Long
bV4GammaRed As Long
bV4GammaGreen As Long
bV4GammaBlue As Long
End TypeBitmap code:
Code:
42 4D 4E 00 00 00 00 00 00 00 36 00 00 00 28 00
00 00 03 00 00 00 02 00 00 00 01 00 18 00 00 00
00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 80 FF 00 00 FF FF 40 80 FF 00
00 00 00 00 FF FF FF 00 FF 00 FF 00 00 00The RGB colors used are
FF 00 00 Red
00 FF FF Cyan
FF 00 FF Magenta
00 FF 80 Green like
FF FF 00 Yellow
FF 80 40 Orange like
From looking at the bitmap dump I see the colors and they appear to be in BGR order and from bottom row horizontally upward. I can also see the width and height in the dump but I don't know how to read the rest of the bytes or to which Type structure they apply to.
This thread is in relations to the other thread I started How To Find Color In A Bitmap and my first thought was to scan the picture in a picturebox pixel by pixel but then realized that could take a very log time and then it occured to me to use the bitmap code itself if I opened the bitmap file and read in the data.