Recent

Author Topic: [SOLVED] SetPart ?  (Read 884 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 347
[SOLVED] SetPart ?
« on: January 15, 2025, 10:11:23 pm »
since there is:
Code: Pascal  [Select][+][-]
  1. function GetPart(const ARect: TRect; ACopyProperties: Boolean=False): TBGRABitmap; override;    
  2.  
is there anything like SetPart ? (set the upper part to some place on another TBGRABitmap)

or do we have to, like
Code: Pascal  [Select][+][-]
  1. BGRABitmap1.Canvas.CopyRect(Dest,BGRABitmap2.Canvas,Source);
  2.  
« Last Edit: January 18, 2025, 08:55:36 pm by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 347
Re: SetPart ?
« Reply #1 on: January 15, 2025, 11:32:19 pm »
DrawPart, I assume. But src canvas is included.
lazarus 3.2-fpc-3.2.2-win32/win64

circular

  • Hero Member
  • *****
  • Posts: 4383
    • Personal webpage
Re: SetPart ?
« Reply #2 on: January 16, 2025, 01:10:21 pm »
Hi BubikolRamios,

I understand you would like to replace a part of the TBGRABitmap image. The function SetPart doesn't exist, however you can use PutImage with the dmSet mode to do that.

If the source image is bigger than the destination rectangle, you can use ClipRect property of the destination image to specify which part can be changed. And then call NoClip to reset the clipping.
Conscience is the debugger of the mind

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 347
Re: SetPart ?
« Reply #3 on: January 18, 2025, 08:51:31 pm »
Thanks, result is split of sec., against 3-4 sec., compared to commented lines.

Code: Pascal  [Select][+][-]
  1. for i := 0 to horizontalSquareCount-1 do
  2.       begin
  3.         for j := 0 to verticalSquareCount-1 do
  4.         begin
  5.           Source := Rect(...);
  6.           Dest :=   Rect(...);
  7.  
  8.  
  9.           //imagePart.Canvas.CopyRect(Dest,image.Canvas,Source);
  10.           imagePart := image.GetPart(Source);
  11.  
  12.           BgraReplace(imagePart,imagePart.RotateCW());
  13.  
  14.           Dest :=   Rect(...);
  15.           Source :=   Rect(...);
  16.  
  17.           //image11.Canvas.CopyRect(Dest,imagePart.Canvas,Source);
  18.           image11.PutImage(Dest.Left,Dest.top,imagePart,dmSet);
  19.  
  20.         end;
  21.       end;  
  22.  
« Last Edit: January 18, 2025, 10:21:17 pm by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

circular

  • Hero Member
  • *****
  • Posts: 4383
    • Personal webpage
Re: [SOLVED] SetPart ?
« Reply #4 on: January 21, 2025, 12:28:21 pm »
Nice  :)

Freeing the imagePart variable may be missing in the loop.

A part from that, seems good to me.

Note that you could as well draw the image directly rotate using PutImageAngle. For efficiency, better to specify rfBox as resample filter parameter.

Regards
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018