Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bitmap

Posted on 1999-06-29
4
Medium Priority
?
277 Views
Last Modified: 2013-12-03
Hi all. How Can I Create A Bitmap From A TRect?
0
Comment
Question by:zeko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1385172
I beg your pardon?  Thats like asking how can I create an apple from an orange.  

UNLESS.... you mean something like, how do you create a bitmap from a specified area - like a screen capture?  Is that what you mean?

Stu
0
 

Author Comment

by:zeko
ID: 1385173
yes I mean that, sorry bad english :)
0
 
LVL 4

Accepted Solution

by:
Radler earned 40 total points
ID: 1385174
Imagining that TRect represent a particular area in your Screen, maybe this solve:

function CaptureBmpRect( Rect : TRect ) : TBitMap;
var
  hdcCompatible, hdcScreen: Hdc;
  hbmScreen : HBitMap;
  OldBmp : THandle;
begin
      Result:=nil;
      hdcScreen := CreateDC('DISPLAY', nil, nil, nil);
      hdcCompatible := CreateCompatibleDC(hdcScreen);
      hbmScreen := CreateCompatibleBitmap(hdcScreen,       GetDeviceCaps(hdcScreen, HORZRES), GetDeviceCaps(hdcScreen,       VERTRES));
      if (hbmScreen = 0) then begin
            DeleteDC(hdcCompatible);
            Exit;
      end;
      OldBmp:=SelectObject(hdcCompatible, hbmScreen);
      BitBlt(hdcCompatible, Rect.Left,Rect.Top, Rect.Rigth,Rect.Bottom,        hdcScreen, 0,0, SRCCOPY);
      SelectObject(hdcCompatible, OldBmp);
      {DeleteObject(Image1.Picture.BitMap.Handle);}
      Result:=TBitMap.Create;
      DeleteObject(Result.Handle);
      if Result <> nil then begin
            Result.Handle:=hbmScreen;
      end;
      DeleteDC(hdcScreen);
      DeleteDC(hdcCompatible);
end;

Sorry, dont check out the code after edition.
0
 

Author Comment

by:zeko
ID: 1385175
Ok. Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

671 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question