Permalink
Browse files

BITMAPINFOHEADER -> BitmapInfoHeader

  • Loading branch information...
grahamboree committed Oct 8, 2012
1 parent 545ac52 commit b8988e235be3db8315aafb667100fda432da04c7
@@ -47,7 +47,7 @@ class CImageIterator
public:
// Constructors
CImageIterator();
- CImageIterator(CxImage *image);
+ CImageIterator(CxImage* inImage);
// Operators
operator CxImage* ();
@@ -128,8 +128,8 @@ inline CImageIterator::CImageIterator(void)
}
/////////////////////////////////////////////////////////////////////
-inline CImageIterator::CImageIterator(CxImage* imageImpl)
-: mImage(imageImpl)
+inline CImageIterator::CImageIterator(CxImage* inImage)
+: mImage(inImage)
{
if (mImage != NULL)
IterImage = mImage->GetBits();
@@ -153,7 +153,7 @@ struct RGBQuad
# pragma pack(1)
-struct BITMAPINFOHEADER
+struct BitmapInfoHeader
{
uint32_t biSize;
int32_t biWidth;
@@ -813,10 +813,10 @@ class DLL_EXP CxImage
static int32_t CompareColors(const void* elem1, const void* elem2);
int16_t m_ntohs(const int16_t word);
int32_t m_ntohl(const int32_t dword);
- void bihtoh(BITMAPINFOHEADER* bih);
+ void bihtoh(BitmapInfoHeader* bih);
void* pDib; //contains the header, the palette, the pixels
- BITMAPINFOHEADER head; //standard header
+ BitmapInfoHeader head; //standard header
CXIMAGEINFO info; //extended information
uint8_t* pSelection; //selected region
uint8_t* pAlpha; //alpha channel
@@ -34,8 +34,8 @@ bool CxImageBMP::Encode(CxFile * hFile)
#if CXIMAGE_SUPPORT_ALPHA
if (GetNumColors() == 0 && AlphaIsValid())
{
- BITMAPINFOHEADER infohdr;
- memcpy(&infohdr, &head, sizeof(BITMAPINFOHEADER));
+ BitmapInfoHeader infohdr;
+ memcpy(&infohdr, &head, sizeof(BitmapInfoHeader));
infohdr.biCompression = BI_RGB;
infohdr.biBitCount = 32;
uint32_t dwEffWidth = ((((infohdr.biBitCount * infohdr.biWidth) + 31) / 32) * 4);
@@ -48,7 +48,7 @@ bool CxImageBMP::Encode(CxFile * hFile)
// Write the file header
hFile->Write(&hdr, min(14, sizeof(BITMAPFILEHEADER)), 1);
- hFile->Write(&infohdr, sizeof(BITMAPINFOHEADER), 1);
+ hFile->Write(&infohdr, sizeof(BitmapInfoHeader), 1);
//and DIB+ALPHA interlaced
uint8_t *srcalpha = AlphaGetPointer();
for (int32_t y = 0; y < infohdr.biHeight; ++y)
@@ -69,11 +69,11 @@ bool CxImageBMP::Encode(CxFile * hFile)
// Write the file header
hFile->Write(&hdr, min(14, sizeof(BITMAPFILEHEADER)), 1);
//copy attributes
- memcpy(pDib, &head, sizeof(BITMAPINFOHEADER));
- bihtoh(static_cast<BITMAPINFOHEADER*>(pDib));
+ memcpy(pDib, &head, sizeof(BitmapInfoHeader));
+ bihtoh(static_cast<BitmapInfoHeader*>(pDib));
// Write the DIB header and the pixels
hFile->Write(pDib, GetSize(), 1);
- bihtoh(static_cast<BITMAPINFOHEADER*>(pDib));
+ bihtoh(static_cast<BitmapInfoHeader*>(pDib));
}
return true;
}
@@ -103,7 +103,7 @@ bool CxImageBMP::Decode(CxFile * hFile)
hFile->Seek(off, SEEK_SET);
}
- BITMAPINFOHEADER bmpHeader;
+ BitmapInfoHeader bmpHeader;
if (!DibReadBitmapInfo(hFile, &bmpHeader))
cx_throw("Error reading BMP info");
uint32_t dwCompression = bmpHeader.biCompression;
@@ -464,27 +464,27 @@ bool CxImageBMP::Decode(CxFile * hFile)
* BITMAPINFO. This function will work with both "old" and "new"
* bitmap formats, but will always return a "new" BITMAPINFO.
*/
-bool CxImageBMP::DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib)
+bool CxImageBMP::DibReadBitmapInfo(CxFile* fh, BitmapInfoHeader *pdib)
{
if ((fh == NULL) || (pdib == NULL))
return false;
- if (fh->Read(pdib, sizeof(BITMAPINFOHEADER), 1) == 0)
+ if (fh->Read(pdib, sizeof(BitmapInfoHeader), 1) == 0)
return false;
bihtoh(pdib);
switch (pdib->biSize) // what type of bitmap info is this?
{
- case sizeof(BITMAPINFOHEADER):
+ case sizeof(BitmapInfoHeader):
break;
case 64: //sizeof(OS2_BMP_HEADER):
- fh->Seek((int32_t)(64 - sizeof(BITMAPINFOHEADER)), SEEK_CUR);
+ fh->Seek((int32_t)(64 - sizeof(BitmapInfoHeader)), SEEK_CUR);
break;
case 124: //sizeof(BITMAPV5HEADER):
- fh->Seek((long)(124-sizeof(BITMAPINFOHEADER)), SEEK_CUR);
+ fh->Seek((long)(124-sizeof(BitmapInfoHeader)), SEEK_CUR);
break;
case sizeof(BITMAPCOREHEADER):
@@ -502,17 +502,17 @@ bool CxImageBMP::DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib)
pdib->biClrUsed = 0;
pdib->biClrImportant = 0;
- fh->Seek((int32_t)(sizeof(BITMAPCOREHEADER) - sizeof(BITMAPINFOHEADER)), SEEK_CUR);
+ fh->Seek((int32_t)(sizeof(BITMAPCOREHEADER) - sizeof(BitmapInfoHeader)), SEEK_CUR);
}
break;
default:
//give a last chance
- if (pdib->biSize > (sizeof(BITMAPINFOHEADER)) &&
+ if (pdib->biSize > (sizeof(BitmapInfoHeader)) &&
(pdib->biSizeImage >= (uint32_t)(pdib->biHeight * ((((pdib->biBitCount * pdib->biWidth) + 31) / 32) * 4))) &&
(pdib->biPlanes == 1) && (pdib->biClrUsed == 0))
{
if (pdib->biCompression == BI_RGB)
- fh->Seek((int32_t)(pdib->biSize - sizeof(BITMAPINFOHEADER)), SEEK_CUR);
+ fh->Seek((int32_t)(pdib->biSize - sizeof(BitmapInfoHeader)), SEEK_CUR);
break;
}
return false;
@@ -47,7 +47,7 @@ class CxImageBMP: public CxImage
#endif // CXIMAGE_SUPPORT_ENCODE
protected:
- bool DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib);
+ bool DibReadBitmapInfo(CxFile* fh, BitmapInfoHeader *pdib);
};
#define BFT_ICON 0x4349 /* 'IC' */
@@ -67,7 +67,7 @@ bool CxImageICO::Decode(CxFile *hFile)
}
// get the bit count for the colors in the icon <CoreyRLucier>
- BITMAPINFOHEADER bih;
+ BitmapInfoHeader bih;
hFile->Seek(off + icon_list[page].dwImageOffset, SEEK_SET);
if (icon_list[page].bWidth==0 && icon_list[page].bHeight==0)
@@ -83,7 +83,7 @@ bool CxImageICO::Decode(CxFile *hFile)
}
else
{ // standard icon
- hFile->Read(&bih,sizeof(BITMAPINFOHEADER),1);
+ hFile->Read(&bih,sizeof(BitmapInfoHeader),1);
bihtoh(&bih);
@@ -328,7 +328,7 @@ bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int32_t nPageCount)
if (!bAppend)
m_dwImageOffset = sizeof(ICONHEADER) + nPages * sizeof(ICONDIRENTRY);
- uint32_t dwBytesInRes = sizeof(BITMAPINFOHEADER)+head.biClrUsed*sizeof(RGBQuad)+imagesize+masksize;
+ uint32_t dwBytesInRes = sizeof(BitmapInfoHeader)+head.biClrUsed*sizeof(RGBQuad)+imagesize+masksize;
ICONDIRENTRY icon_list={
(uint8_t)head.biWidth,
@@ -340,8 +340,8 @@ bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int32_t nPageCount)
m_dwImageOffset
};
- BITMAPINFOHEADER bi={
- sizeof(BITMAPINFOHEADER),
+ BitmapInfoHeader bi={
+ sizeof(BitmapInfoHeader),
head.biWidth,
2*head.biHeight,
1,
@@ -350,8 +350,8 @@ bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int32_t nPageCount)
0, 0, 0, 0
};
/*
- BITMAPINFOHEADER bi={
- sizeof(BITMAPINFOHEADER),
+ BitmapInfoHeader bi={
+ sizeof(BitmapInfoHeader),
head.biWidth,
2*head.biHeight,
1,
@@ -404,7 +404,7 @@ bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int32_t nPageCount)
#endif //CXIMAGE_SUPPORT_PNG
{ // standard icon
bihtoh(&bi);
- hFile->Write(&bi,sizeof(BITMAPINFOHEADER),1); //write the image header
+ hFile->Write(&bi,sizeof(BitmapInfoHeader),1); //write the image header
bihtoh(&bi);
bool bTransparent = info.nBkgndIndex >= 0;
View
@@ -16,7 +16,7 @@ void CxImage::Startup(uint32_t imagetype)
pDib = pSelection = pAlpha = NULL;
ppLayers = ppFrames = NULL;
//init structures
- memset(&head, 0, sizeof(BITMAPINFOHEADER));
+ memset(&head, 0, sizeof(BitmapInfoHeader));
memset(&info, 0, sizeof(CXIMAGEINFO));
//init default attributes
info.dwType = imagetype;
@@ -133,7 +133,7 @@ void CxImage::Copy(const CxImage& src, bool copypixels, bool copyselection, bool
//copy the attributes
memcpy(&info, &src.info, sizeof(CXIMAGEINFO));
- memcpy(&head, &src.head, sizeof(BITMAPINFOHEADER)); // [andy] - fix for bitmap header DPI
+ memcpy(&head, &src.head, sizeof(BitmapInfoHeader)); // [andy] - fix for bitmap header DPI
//rebuild the image
Create(src.GetWidth(), src.GetHeight(), src.GetBpp(), src.GetType());
//copy the pixels and the palette, or at least copy the palette only.
@@ -244,8 +244,8 @@ void* CxImage::Create(uint32_t dwWidth, uint32_t dwHeight, uint32_t wBpp, uint32
info.dwEffWidth = ((((wBpp * dwWidth) + 31) / 32) * 4);
info.dwType = imagetype;
- // initialize BITMAPINFOHEADER
- head.biSize = sizeof(BITMAPINFOHEADER); //<ralphw>
+ // initialize BitmapInfoHeader
+ head.biSize = sizeof(BitmapInfoHeader); //<ralphw>
head.biWidth = dwWidth; // fill in width from parameter
head.biHeight = dwHeight; // fill in height from parameter
head.biPlanes = 1; // must be 1
@@ -279,9 +279,9 @@ void* CxImage::Create(uint32_t dwWidth, uint32_t dwHeight, uint32_t wBpp, uint32
#endif //CXIMAGE_SUPPORT_ALPHA
// use our bitmap info structure to fill in first part of
- // our DIB with the BITMAPINFOHEADER
- BITMAPINFOHEADER* lpbi;
- lpbi = (BITMAPINFOHEADER*)(pDib);
+ // our DIB with the BitmapInfoHeader
+ BitmapInfoHeader* lpbi;
+ lpbi = (BitmapInfoHeader*)(pDib);
*lpbi = head;
info.pImage = GetBits();
@@ -371,15 +371,15 @@ bool CxImage::Transfer(CxImage& from, bool bTransferFrames /*=true*/)
if (!Destroy())
return false;
- memcpy(&head, &from.head, sizeof(BITMAPINFOHEADER));
+ memcpy(&head, &from.head, sizeof(BitmapInfoHeader));
memcpy(&info, &from.info, sizeof(CXIMAGEINFO));
pDib = from.pDib;
pSelection = from.pSelection;
pAlpha = from.pAlpha;
ppLayers = from.ppLayers;
- memset(&from.head, 0, sizeof(BITMAPINFOHEADER));
+ memset(&from.head, 0, sizeof(BitmapInfoHeader));
memset(&from.info, 0, sizeof(CXIMAGEINFO));
from.pDib = from.pSelection = from.pAlpha = NULL;
from.ppLayers = NULL;
@@ -403,7 +403,7 @@ void CxImage::Ghost(const CxImage* from)
{
if (from)
{
- memcpy(&head, &from->head, sizeof(BITMAPINFOHEADER));
+ memcpy(&head, &from->head, sizeof(BitmapInfoHeader));
memcpy(&info, &from->info, sizeof(CXIMAGEINFO));
pDib = from->pDib;
pSelection = from->pSelection;
@@ -97,7 +97,7 @@ void CxImage::SetXDPI(int32_t dpi)
if (dpi<=0) dpi = CXIMAGE_DEFAULT_DPI;
info.xDPI = dpi;
head.biXPelsPerMeter = (int32_t) floor(dpi * 10000.0 / 254.0 + 0.5);
- if (pDib) ((BITMAPINFOHEADER*)pDib)->biXPelsPerMeter = head.biXPelsPerMeter;
+ if (pDib) ((BitmapInfoHeader*)pDib)->biXPelsPerMeter = head.biXPelsPerMeter;
}
////////////////////////////////////////////////////////////////////////////////
/**
@@ -108,7 +108,7 @@ void CxImage::SetYDPI(int32_t dpi)
if (dpi<=0) dpi = CXIMAGE_DEFAULT_DPI;
info.yDPI = dpi;
head.biYPelsPerMeter = (int32_t) floor(dpi * 10000.0 / 254.0 + 0.5);
- if (pDib) ((BITMAPINFOHEADER*)pDib)->biYPelsPerMeter = head.biYPelsPerMeter;
+ if (pDib) ((BitmapInfoHeader*)pDib)->biYPelsPerMeter = head.biYPelsPerMeter;
}
////////////////////////////////////////////////////////////////////////////////
/**
@@ -753,7 +753,7 @@ int32_t CxImage::m_ntohl(const int32_t dword)
((dword >> 8) & 0xff00) | ((dword >> 24) & 0xff);
}
////////////////////////////////////////////////////////////////////////////////
-void CxImage::bihtoh(BITMAPINFOHEADER* bih)
+void CxImage::bihtoh(BitmapInfoHeader* bih)
{
bih->biSize = m_ntohl(bih->biSize);
bih->biWidth = m_ntohl(bih->biWidth);
@@ -779,7 +779,7 @@ const char* CxImage::GetLastError()
uint32_t CxImage::DumpSize()
{
uint32_t n;
- n = sizeof(BITMAPINFOHEADER) + sizeof(CXIMAGEINFO) + GetSize();
+ n = sizeof(BitmapInfoHeader) + sizeof(CXIMAGEINFO) + GetSize();
#if CXIMAGE_SUPPORT_ALPHA
if (pAlpha){
@@ -818,8 +818,8 @@ uint32_t CxImage::Dump(uint8_t * dst)
{
if (!dst) return 0;
- memcpy(dst,&head,sizeof(BITMAPINFOHEADER));
- dst += sizeof(BITMAPINFOHEADER);
+ memcpy(dst,&head,sizeof(BitmapInfoHeader));
+ dst += sizeof(BitmapInfoHeader);
memcpy(dst,&info,sizeof(CXIMAGEINFO));
dst += sizeof(CXIMAGEINFO);
@@ -885,8 +885,8 @@ uint32_t CxImage::UnDump(const uint8_t * src)
uint32_t n = 0;
- memcpy(&head,src,sizeof(BITMAPINFOHEADER));
- n += sizeof(BITMAPINFOHEADER);
+ memcpy(&head,src,sizeof(BitmapInfoHeader));
+ n += sizeof(BitmapInfoHeader);
memcpy(&info,&src[n],sizeof(CXIMAGEINFO));
n += sizeof(CXIMAGEINFO);
@@ -17,7 +17,7 @@ uint32_t CxImage::GetPaletteSize()
void CxImage::SetPaletteColor(uint8_t idx, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha)
{
if ((pDib)&&(head.biClrUsed)){
- uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BITMAPINFOHEADER);
+ uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BitmapInfoHeader);
if (idx<head.biClrUsed){
int32_t ldx=idx*sizeof(RGBQuad);
iDst[ldx++] = (uint8_t) b;
@@ -32,7 +32,7 @@ void CxImage::SetPaletteColor(uint8_t idx, uint8_t r, uint8_t g, uint8_t b, uint
void CxImage::SetPaletteColor(uint8_t idx, RGBQuad c)
{
if ((pDib)&&(head.biClrUsed)){
- uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BITMAPINFOHEADER);
+ uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BitmapInfoHeader);
if (idx<head.biClrUsed){
int32_t ldx=idx*sizeof(RGBQuad);
iDst[ldx++] = (uint8_t) c.rgbBlue;
@@ -47,7 +47,7 @@ void CxImage::SetPaletteColor(uint8_t idx, RGBQuad c)
void CxImage::SetPaletteColor(uint8_t idx, COLORREF cr)
{
if ((pDib)&&(head.biClrUsed)){
- uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BITMAPINFOHEADER);
+ uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BitmapInfoHeader);
if (idx<head.biClrUsed){
int32_t ldx=idx*sizeof(RGBQuad);
iDst[ldx++] = (uint8_t) GetBValue(cr);
@@ -65,7 +65,7 @@ void CxImage::SetPaletteColor(uint8_t idx, COLORREF cr)
RGBQuad* CxImage::GetPalette() const
{
if ((pDib)&&(head.biClrUsed))
- return (RGBQuad*)((uint8_t*)pDib + sizeof(BITMAPINFOHEADER));
+ return (RGBQuad*)((uint8_t*)pDib + sizeof(BitmapInfoHeader));
return NULL;
}
////////////////////////////////////////////////////////////////////////////////
@@ -76,7 +76,7 @@ RGBQuad CxImage::GetPaletteColor(uint8_t idx)
{
RGBQuad rgb = {0,0,0,0};
if ((pDib)&&(head.biClrUsed)){
- uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BITMAPINFOHEADER);
+ uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BitmapInfoHeader);
if (idx<head.biClrUsed){
int32_t ldx=idx*sizeof(RGBQuad);
rgb.rgbBlue = iDst[ldx++];
@@ -366,7 +366,7 @@ uint8_t CxImage::GetNearestIndex(RGBQuad c)
info.last_c = c;
info.last_c_isvalid = true;
- uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BITMAPINFOHEADER);
+ uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BitmapInfoHeader);
int32_t distance=200000;
int32_t i,j = 0;
int32_t k,l;
@@ -493,7 +493,7 @@ void CxImage::SetGrayPalette()
void CxImage::BlendPalette(COLORREF cr,int32_t perc)
{
if ((pDib==NULL)||(head.biClrUsed==0)) return;
- uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BITMAPINFOHEADER);
+ uint8_t* iDst = (uint8_t*)(pDib) + sizeof(BitmapInfoHeader);
uint32_t i,r,g,b;
RGBQuad* pPal=(RGBQuad*)iDst;
r = GetRValue(cr);
Oops, something went wrong.

0 comments on commit b8988e2

Please sign in to comment.