Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Help! Mangled Bitmaps!

This topic is 6718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all! I've got a problem with my game that I have had a great deal of difficulty solving and I'd appreciate some input. My game is running at 800x600 16bpp using a modified version of Andre Lamothe's WGPDUMB game library and the DirectX 6 SDK. It allows bitmaps to be created in VRAM or System RAM. The systems on which I am testing the game are: Celeron 400 ATI Xpert 128 16MB Windows 98 OSR2 w/ DirectX 7 128 MB of RAM P2-350 ATI Xpert '98 8MB Windows 98 w/ DirectX 7 64 MB of RAM My problem is that attempting to load the bitmaps into video memory first results in serious mangling when they are displayed. It's like my bitmaps have been skewed by a ridiculous amount. However, this happens only for certain bitmaps. Some come out fine (ie. the 800 x 600 background), and some don't. When all of the bitmaps are forced into system memory, they come out perfectly, but performance takes a serious hit (I notice a serious performance difference between the Celeron and the P2; Given the nature of my game, the frame rates should max out at the same limit) - especially on some of the slower systems that I've tested on (ie. P166). This shouldn't be! One thing I notice is that when the game is starting up and a blank screen marks the transition between Windowed & full screen mode, there is a mass of visual garbage at the very bottom of the screen. I don't know if it's related to my problem. If anyone could provide direction as to how I can resolve this problem and load bitmaps into video memory without the mangling, I would greatly appreciate it. Thanks in advance! Edited by - Peregrine on 6/21/00 10:39:55 AM

Share this post

Link to post
Share on other sites
Well I can tell you what your problem is, but I can't tell you how to fix it since I'm having the same problem and aren't smart enough to do anything about it.

Each scanline in a bitmap file is padded with zeros to a 32bit boundary. That explains why your 800x600 bitmap is fine and my 128x128 bitmaps are groovy, but anything not on a 32bit boundary has to be accounted for on it's way to the surface.

Here's the code that I use to get an image buffer onto a surface. It inverts the scanlines and everything like it's supposed to (24bit color, that's what the *3 is for) but when I get an odd sized bitmap i get the skew you are talking about.

for (i=0;i(lessthan sign)image->height;i++)
memcpy(ddptr+i*pitch, bitmapData+i*(image->width*3), image->width*3);

Since you have the problem in video memory and not system memory, that has something to do with the stride, or pitch of your video memory. Pitch is the distance in bytes from one pixel to the pixel directly below it.

You can see that I account for pitch in the destination of the memory copy. I just don't know how to account for the padding of the bitmap files. Any ideas anyone?



Edited by - calen on June 21, 2000 10:38:22 PM

Share this post

Link to post
Share on other sites
Peregrine: I know your problem and because of that I scrapped lamothes bitmap loader...i just load the bitmap with loadimage and blit it to a surface with bitblt...bonus of this is there is half the amount of code in your function and it converts the bmp to the correct bit depth for you!



Share this post

Link to post
Share on other sites
Also, it should be noted that the macro he gives in the book to convert rgb into an int only works for 5-5-5 mode. If your card is 5-6-5 mode you need to modify it like so:

_RGB( r, g, b ) ( ( r << 11 ) / ( g << 5 ) / ( b ) )

I think : )


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!