Sign in to follow this  

How to blit single elements from a big BMP?

This topic is 4832 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
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

This topic is 4832 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this