Dies ist etwas von meinem Bitmask-Code (monochrome Bitmaps). Es gibt kein Problem mit der Bitmask_Create() - Funktion. Ich habe es mit Öffnen, Laden und Speichern von Windows-Monochrom-Bitmaps getestet, und es funktioniert großartig. Die GetPixel- und SetPixel-Funktionen, die ich gemacht habe, scheinen jedoch nicht richtig zu funktionieren. In einigen Fällen scheinen sie gut zu funktionieren, abhängig von den Bitmap-Dimensionen.Monochrome Bitmap SetPixel/GetPixel Probleme ... Win32 C-Code
Wenn jemand helfen könnte, würde ich es begrüßen. Es macht mich wahnsinnig. Danke.
typedef struct _GL_BITMASK GL_BITMASK;
struct _GL_BITMASK {
int nWidth; // Width in pixels
int nHeight; // Height in pixels
int nPitch; // Width of scanline in bytes (may have extra padding to align to DWORD)
BYTE *pData; // Pointer to the first byte of the first scanline (top down)
};
int BitMask_GetPixel(GL_BITMASK *pBitMask, int x, int y)
{
INT nElement = ((y * pBitMask->nPitch) + (x/8));
PBYTE pElement = pBitMask->pData + nElement;
BYTE bMask = 1 << (7 - (x % 8));
return *pElement & bMask;
}
void BitMask_SetPixel(GL_BITMASK *pBitMask, int x, int y, int nPixelColor)
{
INT nElement = x/8;
INT nScanLineOffset = y * pBitMask->nPitch;
PBYTE pElement = pBitMask->pData + nScanLineOffset + nElement;
BYTE bMask = 1 << (7 - (x % 8));
if(*pElement & bMask)
{
if(!nPixelColor) return;
else *pElement ^= bMask;
}
else
{
if(nPixelColor) return;
else *pElement |= bMask;
}
}
GL_BITMASK *BitMask_Create(INT nWidth, INT nHeight)
{
GL_BITMASK *pBitMask;
int nPitch;
nPitch = ((nWidth/8) + 3) & ~3;
pBitMask = (GL_BITMASK *)GlobalAlloc(GMEM_FIXED, (nPitch * nHeight) + sizeof(GL_BITMASK));
if(!pBitMask)
return (GL_BITMASK *)NULL;
pBitMask->nPitch = nPitch;
pBitMask->nWidth = nWidth;
pBitMask->nHeight = nHeight;
pBitMask->pData = (PBYTE)pBitMask + sizeof(GL_BITMASK);
return pBitMask;
}
änderte ich den Pitch-Code, aber die SetPixel und GetPixel Funktionen sind noch nicht funktioniert ... wenn ich die Bitmap speichere, ist alles schwarz ... die Bitmap-Speicherfunktion funktioniert gut; Ich habe es aus einer Bitmap getestet, die in einen Bitmaskenpuffer geladen wurde. (Danke für den Hinweis, obwohl) – oldSkool