Jump to content
  • Advertisement
Sign in to follow this  
BastetFurry

How to blit single elements from a big BMP?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Folks! Is there a way, with vanilia Win32, to get small elements out of a big bitmap and draw them on the screen? So Long, The Werelion!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by BastetFurry
Hi Folks!

Is there a way, with vanilia Win32, to get small elements out of a big bitmap and draw them on the screen?


Assuming you mean GDI (old stuff) functions, you should use GDI BitBlt/StretchBlt functions.

BOOL BitBlt(
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
);

BOOL StretchBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
)

Share this post


Link to post
Share on other sites
Thanks, you saved my day(or night...) ;)

I am using BCX right now and your suggestion produced this, what works.

sub blitpart(DesthWnd as HWND, hBitmap as HBITMAP, LtDest as int, TopDest as int,LtSrc as int, TopSrc as int)
dim DesHDC as HDC
dim MemHDC as HDC
DesHDC = GetDC(DesthWnd)
MemHDC = CreateCompatibleDC(DesHDC)
DeleteObject(SelectObject(MemHDC,hBitmap))
SetMapMode(MemHDC,GetMapMode(DesHDC))
StretchBlt (DesHDC,LtDest,TopDest,8,8,MemHDC,LtSrc,TopSrc,8,8,SRCCOPY)
ReleaseDC(DesthWnd,DesHDC)
DeleteDC(MemHDC)
end sub

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!