Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to copy a polygon region from one bitmap to another Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
29-Aug-02
Category
Graphic
Language
Delphi 2.x
Views
100
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

I have 3 Bitmaps. I copy BM2 on BM1. Then the problem: Copy a defined polygon from 
BM3 (or BM2) into BM1. I only want to map the defined polygon into BM1 without 
destroying any pixels outside the poly (within the rectangle).

Answer:

Here is one way you can try. It defines a polygon shaped clip region for the 
destination bitmap, then copies the origin bitmap:

1   { ... }
2   var
3     pts: array of TPoint;
4     rgn: HRgn;
5   begin
6     SetLength(pts, 4);
7     pts[0] := Point(0, 0);
8     pts[1] := Point(50, 20);
9     pts[2] := Point(20, 50);
10    pts[3] := pts[0];
11    rgn := CreatePolygonRgn(pts[0], 4, Winding);
12    SelectClipRgn(bm1.Canvas.Handle, rgn);
13    bm1.Canvas.Copyrect(rect(0, 0, bm2.width, bm2.height),
14      bm2.canvas, rect(0, 0, bm2.width, bm2.height);
15      DeleteObject(rgn);
16  end;
17  { ... }


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC