delphi - How to draw part of a image? -
I have a normal bitmap that is populated with a PNGI image The following code shows the whole picture; But for example I have to show the sample below which I am looking for. I basically want to reduce virtual "space" where it will be featured. Note that I can not change the shape of the paintbox for reasons only because if someone asks what he can do, I think that I have to use Rects or some copy function, but I did not understand myself, did anyone understand Know how to do that?
Process TForm1.PaintBox1Paint (Sender: Tubect); Start Paintbox 1. Canvas. Brush. Color: clubback; Paint box 1 Brush. Style: = Bisolid; PaintBox1.Canvas.FillRect (GameWindow.Screen.ClientRect); Paint box 1 Katvana Dr. Draw (0, 0, FBIMAP, FOPCity); End;
In a way, modify the canvas clipping area of your paintbox:
... IntersectClipRect (Paint box 1. canvas. Circle, 20, 20, paint box 1. wide - 20, paint box 1. hi-20); Paint box 1 Katvana Dr. Draw (0, 0, FBIMAP, FOPCity); Of course, I'm sure you know that (0, 0
in your canvas.DRA call Coordinates are where you can attract to like:. ... FBitmap.Canvas.CopyRect (Rect (0, 0, 80, 80), FBitmap.Canvas, Rect (20, 20, 100, 100)); FBitmap.SetSize (80, 80); PaintBox1.Canvas.Draw (20, 20, FBitmap, FOpacity);
You do not want to clip the area of the paintbox, and will not want to modify your source bitmap (FBITMAP), and do not make it a temporary copy If you want, you can directly send AlphaBlend
instead of via Canvas.Draw
:
on BlendFn: TBlendFunction; BlendFn.BlendOp start: = AC_SRC_OVER; BlendFn.BlendFlags: = 0; BlendFn.SourceConstantAlpha: FOpacity; BlendFn.AlphaFormat: = AC_SRC_ALPHA; Winapi.windows.AlphaBlend (PaintBox1.Canvas.Handle, 20, 20, PaintBox1.Width - 20, PaintBox1.Height - 20, FBitmap.Canvas.Handle, 20, 20, PaintBox1.Width - 20, Pay IntBox1.Height - 20 , BlendFn);
Comments
Post a Comment