bitmap problem

Started by
5 comments, last by PPCThug 21 years, 1 month ago
I made a program to load a bit map with text that reads "new game", but when it runs the bit map is doubled like "new game new game" and there is garbage underneath it, like dots and lines of random color. if this is not enough info I will post the source code, but I hope that will not be necessary. heres the 24 to 16 bit convesion, since the bit map is 24 bit it might be the problem
  

 
    for (int index_y = 0; index_y < bitmap.bitmapinfoheader.biHeight; index_y++)
        {
        for (int index_x = 0; index_x < bitmap.bitmapinfoheader.biWidth; index_x++)
                {
                // get BGR values, note the scaling down of the channels, so that they

                // fit into the 5.6.5 format

                UCHAR blue  = (bitmap.buffer[index_y*bitmap.bitmapinfoheader.biWidth*3 + index_x*3 + 0]) >> 3,
                green = (bitmap.buffer[index_y*bitmap.bitmapinfoheader.biWidth*3 + index_x*3 + 1]) >> 3,
                red   = (bitmap.buffer[index_y*bitmap.bitmapinfoheader.biWidth*3 + index_x*3 + 2]) >> 3;
                
                // this builds a 16 bit color value in 5.6.5 format (green dominant mode)

                USHORT pixel = _RGB16BIT565(red,green,blue);
                
                // write the pixel

                image_buffer[index_x + (index_y*ddsd.lPitch >> 1)] = pixel;
                
                } // end for index_x         

                        
        } // end for index_y

    
  
Bloodshed Dev-C++ 4.01 DX 8.0a DX SDK 6.1 win98 #define WIN32_LEAN_AND_MEAN the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis
Advertisement
One problem that I see is that you aren''t taking into account the fact that each line of a bitmap is a multiple of 4 bytes. For example, say you had a 24 bit RGB bitmap that was 5 pixels wide. Each line of the bitmap only requires 15 bytes...however, an extra byte will be padded onto the end of each line so that it is 16 bytes (multiple of 4 bytes).

This will cause all kinds of problems in your conversion from 24 bit to 16 bit...all your memory offsets will be wrong.
1: If you don''t like the code talk Andre LaMothe, he wrote it.
2: the bitmap whas 160 pixels wide so I don''t think that whas the problem, tho I will try to fix it. (why multiples of 4 bytes?)


Bloodshed Dev-C++ 4.01
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis
how do I find the bit format for the screen? in other words 5.5.5 or 5.6.5? I know this is in my book but my eyes are bugging out. yes this has something to do with this subject.


Bloodshed Dev-C++ 4.01
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis
so to get the pixel format

lpdd4->GetDisplayMode(ddsd)

so ddsd.DDPIXELFORMAT.dwRBitMask holds a unsigned long/DWORD of the Red bit mask,
ddsd.DDPIXELFORMAT.dwGBitMask holds the green bit mask,
and ddsd.DDPIXELFORMAT.dwBBitMask holds the blue bit mask.

in directx sdk help file it listed off screen Surface Formats, and Texture Map Formats. under 16 bit bit depth there are two entries. if I convert the hex entries into dec and add red green and blue I get ether 65536(5.6.5) or 32768(5.5.5)
so the fallowing should give me the pixel format right?

if (ddsd.ddpixelformat.dwRBitMask == 63488)
{
iPixelFormat = 565;
}

if (ddsd.ddpixelformat.dwRBitMask == 31744)
{
iPixelFormat = 555;
}


Bloodshed Dev-C++ 4.01
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis
this code

  if (FAILED(lpddsprimary->GetPixelFormat(lpDDPixelFormat)))   {   return(0);   }      if (lpDDPixelFormat.dwRBitMask == 63488)   {   iPixelFormat = 565;   erasecolor = _RGB16BIT565(255, 255, 255);      }      if (lpDDPixelFormat.dwRBitMask == 31744)   {   iPixelFormat = 555;   erasecolor = _RGB16BIT555(255, 255, 255);   }  


is giving me this error {request for member ''dwRBitMask'' in ''lpDDPixelFormat'', which is}
any help would be greatly appreciated


Bloodshed Dev-C++ 4.01
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis
it''s one thing to be bashed, but to be completely ignored is disturbing. I could I atleast get a small insult or something?


Bloodshed Dev-C++ 4.01
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis

This topic is closed to new replies.

Advertisement