Jump to content
  • Advertisement

Archived

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

The_Minister

Doesn't show rectangular bitmaps right

This topic is 6940 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

Yo guys, this problem is frying my brain. I am writing an API based on DirectX for my game, and I have just finished displaying bitmaps, with my own load functions etc. So I load the bitmap, make a surface for it and copy it, pixel by pixel, to the surface. Then I ditch the bitmap''s old buffer. This works great for square bitmaps, but not for rectangular ones. When I blit a rectangular one, it appears heavily distorted. I first thought this was some stupid mistake when I was using Width instead of height, and because they are square it didn''t matter, but I went through the code over and over and I can''t find a single place that I did this in. I suspect the function that copies the buffer to the surface, shown here: int Bitmap::CopyBitmapToSurface (BITMAP_FILE_PTR bitmap, LPDDSURFACEDESC2 ddsd) { UCHAR *Surface = (UCHAR *)ddsd->lpSurface; // the drawing surface // copy pixel by pixel for (int index_y = 0; index_y < bitmap->InfoHeader.biHeight; index_y++) for (int index_x = 0; index_x < bitmap->InfoHeader.biWidth; index_x++) Surface[index_x + index_y * int(ddsd->lPitch)] = bitmap->buffer[index_x + index_y * bitmap->InfoHeader.biWidth]; return 1; } If this seems perfect, like it does to me, then the problem must be somewhere else... Anyways thanks for your time, and if you can help me, well that''s even better. The_Minister

Share this post


Link to post
Share on other sites
Advertisement
Here is a screenshot, followed by what the bitmap is supposed to look like.




Note that I have converted the to .gif for quicker download.


The_Minister

Edited by - The_Minister on 4/23/00 12:15:49 PM

Share this post


Link to post
Share on other sites
I haven't studied the bitmap structure in detail so I'm not sure that this is true. But each row in the image may infact be longer than the actual width of the image in pixels. They are usually padded for 32 bit alignment. I see that you use lPitch on the DDSurface, isn't there something similar in the bitmap structure?


- WitchLord




Edited by - WitchLord on 4/23/00 12:51:05 PM

Share this post


Link to post
Share on other sites
It works for the other bitmaps?
Crazy idea but: Maybe, for some reason, biWidth is the same as biHeight?

Ok I''ve been putting this off for a while now, but it looks like I''m going to need it. How do you print numbers using TextOut, or add them to char*''s? Gee I feel stupid asking that, but I have to learn too

I need this because, as said by someone else before, I can''t use the debugger line-by-line after I hit the lock.

Any help whatsoever would be appreciated, thanks again.


The_Minister

Share this post


Link to post
Share on other sites
You print numbers in a string by using sprintf()

char Str[256];
sprintf(Str,"Number: %d\n", 128);

This creates the string: "Number: 128", that you may then use in TextOut.

- WitchLord

Share this post


Link to post
Share on other sites
Here is the BITMAP_FILE struct, as from LaMothe:


typedef struct
{
BITMAPFILEHEADER FileHeader; // file header is stored here
BITMAPINFOHEADER InfoHeader; // infoheader is stored here

PALETTEENTRY palette[256]; // palette is translated from BGR to RGB and stored here

UCHAR *buffer; // image is stored here
} BITMAP_FILE, *BITMAP_FILE_PTR;


I examined BITMAPINFOHEADER and the only thing denoting width in pixels, is biWidth.

Also the bitmaps are all 8-bit, with a palette, and the display is 8-bit. LOL I JUST ENDED OFF A SENTENCE WITH A SEMI-COLON. Hmm I need to get some air...


The_Minister

Share this post


Link to post
Share on other sites
Here''s my code for using TextOut (It prints green text w/ a black shadow.)

HRESULT DebugOut(int x, int y, char *szText)
{
// Get the device context of the screen
HDC hDC;
g_pBackBuffer->GetDC(&hDC);

// Make sure it prints transparently
SetBkMode( hDC, TRANSPARENT );

// Set an appropriate color
SetTextColor(hDC, RGB(0,0,0));
ExtTextOut( hDC, x+1, y+1, 0, NULL, szText, strlen(szText), NULL );
SetTextColor(hDC, RGB(0,255,0));
ExtTextOut( hDC, x, y, 0, NULL, szText, strlen(szText), NULL );

// Release the DC
g_pBackBuffer->ReleaseDC(hDC);

// Return OK
return DD_OK;
}

lntakitopi@aol.com
http://geocities.com/guanajam/

Share this post


Link to post
Share on other sites
It says ''sprintf - undeclared identifier''. The weird thing is that when I hover the mouse over it, it tells me it''s definition line, and it shows the parameter list when I open the paranthesis. Do I need to include something?
At the moment I just have ddraw.h, windows.h and windowsx.h, excluding my api includes.


char *Msg;

sprintf(Msg, "Bitmap Width: %d Bitmap Height: %d\n", bitmap->InfoHeader.biWidth, bitmap->InfoHeader.biHeight);
ShowMessage (Msg, 50);



The_Minister

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!