• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

Baine

going from 24bit color to 16bit color

5 posts in this topic

Howdy.. I''m working through a book that i picked up recently.. "Windows Game Programming for Dummies" By Andre LaMothe.. anywho.. in Chapter 10 it''s explain how to load fullscreen bitmaps, and the source code on the cd is supposed to demonstrate that. Now.. when you compile and run the program, (Prog10_5.cpp for anybody that has read this book) when you give it a 24bit bitmap to display, it corrupts the color scheme horribly. Almost completely green. Now when i checked the source i noticed that if the bitmap of the given file is 24bit, the program automatically converts it to 16bit. I don''t know if the bitmap was supposed to be displayed in green, but somehow i don''t think so. If you just load up the source .bmp in paint or whatever it looks fine.. so I guess what i''m asking is, can anybody help me out with the following algorithm? I think the problem is that it''s not addressing the red components of the bitmap properly but i could be way off. I understand the indexing of the loop, but the >> shift right operator has me a little confused. More than likely due to my less-than-adequate knowledge of how these colors, (8/16/32bit), are built up. any advice would be helpful. ///////////////////////////////////////////////////////////////// // now convert each 24 bit RGB value into a 16 bit value for (index=0; index < bitmap->bitmapinfoheader.biWidth* bitmap->bitmapinfoheader.biHeight; index++) { // extract RGB components (in BGR order), note the scaling UCHAR blue = (temp_buffer[index*3 + 0] >> 3), green = (temp_buffer[index*3 + 1] >> 3), red = (temp_buffer[index*3 + 2] >> 3); // build up 16 bit color word USHORT color = _RGB16BIT(red,green,blue); // write color to buffer ((USHORT *)bitmap->buffer)[index] = color; } // end for index //////////////////////////////////////////////////////////////// temp_buffer is a temporary placeholder for the 24bit bitmap, memory allocated accordingly bitmap->buffer is the actual working bitmap structure.. I''m guessing that the r,g,b components of temp_buffer must be copied here. _RGB16BIT is a macro designed to build up a 16 bit color hmm.. if you could point me toward a site that could help me understand how these colors are built up, and how to index through them properly.. that would probably be the best solution, but thanks for any advice groovy ern.
0

Share this post


Link to post
Share on other sites
If i remember correctly (i read that book a very long time ago) the a. lamothe gives instructions in the extras / something like that folder on the cd. I remember that his code was only ready to load 8 - bit bitmaps. On his site or somewhere on the cd, he gives an article on loading 24/16 bit bitmaps. good luck
0

Share this post


Link to post
Share on other sites
Yeah only problem is that in LaMothe''s book it only works for 565 video cards not 555. I should have some code to do it correctly. I''ll post it when I get home.




...A CRPG in development...

Need help? Well, go FAQ yourself.
0

Share this post


Link to post
Share on other sites
LaMothe has 16 bit versions of all the functions on the CD but this should replace LaMothe's Load_Bitmap_File16() because his only works on 565 video cards, not 555. All his other functions should work though...


    

int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)

{

// this function opens a bitmap file and loads the data into bitmap




int file_handle, // the file handle


index; // looping index




UCHAR *temp_buffer = NULL; // used to convert 24 bit images to 16 bit


OFSTRUCT file_data; // the file data information




// open the file if it exists


if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1)

return(0);



// now load the bitmap file header


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



// test if this is a bitmap file


if (bitmap->bitmapfileheader.bfType!=BITMAP_ID)

{

// close the file


_lclose(file_handle);



// return error


return(0);

} // end if




// now we know this is a bitmap, so read in all the sections




// first the bitmap infoheader




// now load the bitmap file header


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



// now load the color palette if there is one


if (bitmap->bitmapinfoheader.biBitCount == 8)

{

_lread(file_handle, &bitmap->palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));



// now set all the flags in the palette correctly and fix the reversed


// BGR RGBQUAD data format


for (index=0; index < MAX_COLORS_PALETTE; index++)

{

// reverse the red and green fields


int temp_color = bitmap->palette[index].peRed;

bitmap->palette[index].peRed = bitmap->palette[index].peBlue;

bitmap->palette[index].peBlue = temp_color;



// always set the flags word to this


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

} // end for index




} // end if




// finally the image data itself


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



// now read in the image


if (bitmap->bitmapinfoheader.biBitCount==8 || bitmap->bitmapinfoheader.biBitCount==16)

{

// delete the last image if there was one


if (bitmap->buffer)

free(bitmap->buffer);



// allocate the memory for the image


if (!(bitmap->buffer = (UCHAR *)malloc(bitmap->bitmapinfoheader.biSizeImage)))

{

// close the file


_lclose(file_handle);



// return error


return(0);

} // end if




// now read it in


_lread(file_handle,bitmap->buffer,bitmap->bitmapinfoheader.biSizeImage);



} // end if


else

if (bitmap->bitmapinfoheader.biBitCount==24)

{

// allocate temporary buffer to load 24 bit image


if (!(temp_buffer = (UCHAR *)malloc(bitmap->bitmapinfoheader.biSizeImage)))

{

// close the file


_lclose(file_handle);



// return error


return(0);

} // end if




// allocate final 16 bit storage buffer


if (!(bitmap->buffer=(UCHAR *)malloc(2*bitmap->bitmapinfoheader.biWidth*bitmap->bitmapinfoheader.biHeight)))

{

// close the file


_lclose(file_handle);



// release working buffer


free(temp_buffer);



// return error


return(0);

} // end if




// now read the file in


_lread(file_handle,temp_buffer,bitmap->bitmapinfoheader.biSizeImage);



// now convert each 24 bit RGB value into a 16 bit value


for (index=0; index < bitmap->bitmapinfoheader.biWidth*bitmap->bitmapinfoheader.biHeight; index++)

{

// build up 16 bit color word


USHORT color;



// build pixel based on format of directdraw surface


if (dd_pixel_format==DD_PIXEL_FORMAT555)

{
pixform=555;

// extract RGB components (in BGR order), note the scaling


USHORT blue = (USHORT)(temp_buffer[index*3 + 0]),

green = (USHORT)(temp_buffer[index*3 + 1]),

red = (USHORT)(temp_buffer[index*3 + 2]);

blue = blue & 248;

blue = blue >> 3;

green = green & 248;

green = green << 2;

red = red & 248;

red = red << 7;



color = red | green | blue;

} // end if 555


else

if (dd_pixel_format==DD_PIXEL_FORMAT565)

{
pixform=565;

// extract RGB components (in BGR order), note the scaling


UCHAR blue = (temp_buffer[index*3 + 0] >> 3),

green = (temp_buffer[index*3 + 1] >> 3),

red = (temp_buffer[index*3 + 2] >> 3);



color=_RGB16BIT565(red,green,blue);



} // end if 565




// write color to buffer


((USHORT *)bitmap->buffer)[index] = color;



} // end for index




// finally write out the correct number of bits


bitmap->bitmapinfoheader.biBitCount=16;



// release working buffer


free(temp_buffer);



} // end if 24 bit


else

{

// serious problem


return(0);



} // end else




#if 0

// write the file info out


printf("\nfilename:%s \nsize=%d \nwidth=%d \nheight=%d \nbitsperpixel=%d \ncolors=%d \nimpcolors=%d",

filename,

bitmap->bitmapinfoheader.biSizeImage,

bitmap->bitmapinfoheader.biWidth,

bitmap->bitmapinfoheader.biHeight,

bitmap->bitmapinfoheader.biBitCount,

bitmap->bitmapinfoheader.biClrUsed,

bitmap->bitmapinfoheader.biClrImportant);

#endif



// close the file


_lclose(file_handle);



// flip the bitmap


Flip_Bitmap(bitmap->buffer,

bitmap->bitmapinfoheader.biWidth*(bitmap->bitmapinfoheader.biBitCount/8),

bitmap->bitmapinfoheader.biHeight);



// return success


return(1);



} // end Load_Bitmap_File






...A CRPG in development...

Need help? Well, go FAQ yourself.


Edited by - Nazrix on July 12, 2001 1:54:01 AM
0

Share this post


Link to post
Share on other sites