Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2016, 08:25 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default low level BitMaps

Hi Guys,
Please do not relate this to TWinControl, I have a canvas from TControl with the HDC handle set and I want to do a StretchBlt onto the canvas.
I do not understand GetDC and ReleaseDC in my code and where ReleaseDC needs to be placed.

HTML Code:
    DC := GetDC(ACanvas.Handle);
    MemBitmap := CreateCompatibleBitmap(DC, ClientRect.Right,  ClientRect.Bottom);
    SetStretchBltMode(DC, STRETCH_HALFTONE);
    GetBrushOrgEx(DC, Point);
    ReleaseDC(0, DC);
Can some one explain please
Reply With Quote
  #2  
Old 10-20-2016, 08:48 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

What GetDC and ReleaseDC do can be found in the MSDN
GetDC
ReleaseDC

Normally you do this in a try/finally
Placement for ReleaseDC is after you're done with the variabel created by GetDC. So your code looks valid
Reply With Quote
  #3  
Old 10-21-2016, 03:10 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default

MSM site explains nothing i can understand
What is a DC to represent
Reply With Quote
  #4  
Old 10-21-2016, 07:43 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

DC = Device Context
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

Sorry, I can try to explain all this but I think MS does a better job

Quote:
A device context is a structure that defines a set of graphic objects and their associated attributes, as well as the graphic modes that affect output
Reply With Quote
  #5  
Old 10-22-2016, 12:32 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default

That's what I needed to read thanks

That means I only Need
HTML Code:
  DC := GetDC(ACanvas.Handle);
    MemBitmap := CreateCompatibleBitmap(DC, ClientRect.Right,  ClientRect.Bottom);
    ReleaseDC(0, DC);
as CreateCompatibleBitmap only has a size difference from the original.

What I do not understand is: -
If I have a HDC and want to make third Compatible Bitmap
Do I call CreateCompatibleBitmap directly?
Reply With Quote
Reply

Tags
delphi, windows

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:54 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.