Archived

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

classes->conversion 2nd problem

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

Recommended Posts

okie, i am still trying to convert Mr LaMothe''s code to classes. i managed to get something like this: this is the header file currently:

class BITMAP_FILE
{
public:

//member functions

int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height);
int Copy_Screen(UCHAR *source_bitmap, UCHAR *dest_buffer, int lpitch, int transparent);

private:

PALETTEENTRY     palette[256];      // we will store the palette here

UCHAR            *buffer;           // this is a pointer to the data

char             *filename;         //L_B_F

UCHAR            *image;            //F_B

int              bytes_per_line;
int              height;
UCHAR            *source_bitmap;    //C_S

UCHAR            *dest_buffer;
int              lpitch;
int              transparent;
};

previously, i used to call this global function: Copy_Screen(bitmap24bit.buffer, primary_buffer, primary_lpitch, 0); where bitmap24bit is part of his BITMAP_FILE_TAG structure.

int BITMAP_FILE::Copy_Screen(UCHAR *source_bitmap, UCHAR *dest_buffer, int lpitch, int transparent)
{
// this function draws the bitmap onto the destination memory surface

// if transparent is 1 then color 0 (8bit) or 0.0.0 (16bit) will be transparent

// note this function does NOT clip, so be carefull!!!

USHORT pixel;        // used to hold pixel value

int index,           // looping vars

pixel_x,
lpitch_2 = lpitch >> 1; // lpitch in USHORT terms

// compute the starting source address

// is this bitmap transparent

if (transparent)
{
// copy each line of bitmap into destination with transparency

for (index=0; index<SCREEN_HEIGHT; index++)
{
// copy the memory

for (pixel_x=0; pixel_x<SCREEN_WIDTH; pixel_x++)
{

} // end if

} // end for index

} // end if

else
{
// non-transparent version

// copy each line of bitmap into destination

int source_bytes_per_line = SCREEN_WIDTH*2;

for (index=0; index < SCREEN_HEIGHT; index++)
{
// copy the memory

} // end for index

} // end else

// return success

return(1);

} // end Copy_Screen


now that the structure exists as a class, how do i modify this member function considering, 1) *source_bitmap is still required? or not? 2) there is part in the function for source address which i dunno how to modify.

Share on other sites
normally for blits, the member function always uses itself as the source and requires only the dest object, dest rect, and dest position (ie the xy in the source you are blitting to). take a look at the directdraw surface interface. you will see a good way to handle this in an oop manner.

looking over your class, i see many things wrong. it seems you took everything and put it all in the class, even if its not needed and dont make sense.

instead of doing the conversion, why not look over some c++ tutorials and learn a bit about oop and creating classes. i know you want to create games, but unless you take the time to learn the basics you wont get very far.

which i did b4

• Forum Statistics

• Total Topics
628696
• Total Posts
2984267

• 19
• 9
• 13
• 13
• 11