Skip to main content
gamedev.net
🔒 Locked

bitmap sizes

Started by Todd Miller Sep 7, 2000 at 10:37 PM 3 replies 300+ views
Original Post
Todd Miller
Todd Miller
Ok, in DirectDraw, I''m simply displaying bitmaps. I convert a 24bit to a 16bit and Blit it to the screen. Now, a bitmap 32x32 or 64x64 displays perfectly. But if I cut it down 16x16 or anything smaller (i.e. 8x8, 4x4, 2x2) it breaks and doesn''t display correctly. Uh.. what is that? Does that normally happen or am I just special?
Quantum
Quantum
doesn''t happen to me..
whats your bitmap loading code?
Bleakcabal
Bleakcabal
I am using very small bitmaps and my code also loads correctly. Altough I havent tried to load anything smaller than 8x8 or maybe 16x16 I shouldnt why it would not work. I think the problem might be with your code.
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
Todd Miller
Todd Miller
Well I figured that. I also thought it was most likely abnormal, but figured I''d check since I''m still farily new to DirectX. I don''t use bitmaps smaller than 8x8 either, but when I realized that the larger bitmaps were fine, but smaller ones weren''t, I just resized them to smaller to see if it happened there too. Uh.. lets see, here''s my bitmap loader:

int Load_Bitmap(BITMAP_FILE_PTR bitmap, char *filename)
{
int file_handle;
int index;
UCHAR *temp_buffer = NULL;
OFSTRUCT file_data;

if ((file_handle = OpenFile(filename,&file_data,OF_READ)) == -1) {
return(0);
}

_lread(file_handle,&bitmap->header,sizeof(BITMAPFILEHEADER));

if (bitmap->header.bfType != BITMAP_ID) {
_lclose(file_handle);
return(0);
}

_lread(file_handle,&bitmap->info,sizeof(BITMAPINFOHEADER));

if(bitmap->info.biBitCount == 8) {
_lread(file_handle,&bitmap->palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));

for(index = 0; index < MAX_COLORS_PALETTE; index++) {
int temp_color = bitmap->palette[index].peRed;
bitmap->palette[index].peRed = bitmap->palette[index].peBlue;
bitmap->palette[index].peBlue = temp_color;

bitmap->palette[index].peFlags = PC_NOCOLLAPSE;
}
}

_lseek(file_handle,-(int)(bitmap->info.biSizeImage),SEEK_END);

if(bitmap->info.biBitCount == 8 || bitmap->info.biBitCount == 16 || bitmap->info.biBitCount == 24) {
if(bitmap->buffer)
free(bitmap->buffer);

if(!(bitmap->buffer = (UCHAR *)malloc(bitmap->info.biSizeImage))) {
_lclose(file_handle);
return(0);
}

_lread(file_handle,bitmap->buffer,bitmap->info.biSizeImage);
}
else {
return(0);
}

_lclose(file_handle);

Flip_Bitmap(bitmap->buffer,bitmap->info.biWidth*(bitmap->info.biBitCount/8),bitmap->info.biHeight);

return(1);
}

int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height)
{
UCHAR *buffer;
int index;

if (!(buffer = (UCHAR *)malloc(bytes_per_line*height)))
return(0);

memcpy(buffer,image,bytes_per_line*height);

for (index=0; index < height; index++)
memcpy(ℑ[((height-1) - index)*bytes_per_line], &buffer[index*bytes_per_line], bytes_per_line);

free(buffer);

return(1);
}


I pretty much just copied that out of a book. Could it be my conversion function to convert from 24bit to 16bit?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.