MFC Device Context SelectObject Drawing to Bitmap -


i'm working on project translating old windows 95 mfc code c++11 using cairo. since i'm not familiar mfc, i'm getting confused different coordinate spaces drawing in original program, , it's difficult finding information , examples explaining these functions.

so here's i'm seeing. in code, seems @ 1 point there new cdc device context being created using createcompatibledc. bitmap object subsequently created. bitmap set new device context using selectobject function. can glean, ddb device dependent bitmap.

for example:

    bmp_dc = new cdc();     bmp_dc->createcompatibledc(null);      int num_bits_per_pixel = bmp_dc->getdevicecaps(numbitspixel);     int num_planes = bmp_dc->getdevicecaps(numplanes);     c_bmp = new cbitmap();     c_bmp->createbitmap(width, height,num_planes,num_bits_per_pixel,null);      bmp_dc->selectobject(c_bmp); 

this new device context gets passed around number of classes perform drawing operations using (bmp_dc->moveto(), lineto, ellipse, etc.). question is, these drawing operations use device context getting draw directly bitmap, , not onto display screen? and, assume bitmap top-left corner origin when drawing?

i noticed there's number of bitblt function calls happen later, , think they're drawing bitmap out onto actual display screen using display screens coordinates. i'm not sure, , hoping clarification. thanks!

it sounds understood perfectly!

the code uses createcompatibledc create memory dc same format physical display (it passes null argument, means use dektop dc). then, draw bitmap, necessary select bitmap memory dc using selectobject, said.

then drawing dc drawing bitmap "inside" memory dc.

finally, bitblt can display bitmap contents (from memory dc) display device. classic implementation of double-buffered drawing avoid flickering during display.

the drawing commands use same coordinate system - top left (0,0) origin.

is there happening contradicts this? if so, perhaps can post more code.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -