🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

GDI TransparentBlt how to?

Started by
1 comment, last by aston2 3 years, 1 month ago

Hi

I have read member r.santana explanation about TransparentBlt function and try to using it

but not work ,because i don't know exactly what i must to do .

I would like to implement it like this :

I need one bitmap image as background 800x600 , and one small image like a sprite 100x120 to blit over

that background.

Then how this two things blit from WM_PAINT?

thanks in advance!

Advertisement

I have found on vazGames site this main things about DC and GDI..Is that proper way ?

I mean it looks that for each bitmap i need to create separate DC like

bmp1dc , bmp_2dc ..etc

is that right?

vaz code :

// go full screen
ChangeDisplaySettings(&game_screen, CDS_FULLSCREEN);

// get the GDI device context
game_dc = GetDC(game_window); 

// select an object (such as white brush)
SelectObject(back_dc, white_brush);

// plot a single pixel with color c
SetPixel(back_dc, xi, yi, c);

// fill rectangle (erase the back buffer)
FillRect(back_dc, &back_rect, black_brush);

// draw an ellipse (circular) to back buffer
Ellipse(back_dc, x1, y1, x2, y2);

// draw a polygon (9 points) to back buffer
Polygon(back_dc, points, 9);

// blit (bit block transfer) or copy back buffer to front buffer
BitBlt(game_dc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, back_dc, 0, 0, SRCCOPY);

// blit a single sprite or block of pixels (no transparency)
BitBlt(back_dc, x, y, BLOCK_SIZE, BLOCK_SIZE, bmp_dc, 0, 0, SRCCOPY);

// blit a single sprite with transparent background color (bug in Win98, only Win ME/XP work)
TransparentBlt(back_dc, Vaz.x, Vaz.y, BLOCK_SIZE, BLOCK_SIZE, bmp_dc, 0, 0, BLOCK_SIZE, BLOCK_SIZE, RGB(0,0,0));

aston2 said:
is that right?

It's been a while since I had to deal with raw GDI, but yes, that is that case. Vanilla WinAPI tends to be on people's shun list for a reason - it hardly provides any middleware layer to simplify the coder's life.

The bitmap really is what the name says: just a map of bits, e.g. storage. A Device Context enables operations on it.

This topic is closed to new replies.

Advertisement