Recent

Author Topic: [SOLVED] CopyRect issue?  (Read 3745 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
[SOLVED] CopyRect issue?
« on: August 22, 2017, 01:23:15 pm »
Hi All and thx in advance.

I am coding a little sprite editor app but am having problems with CopyRect.

When I do the following:
SprSheetImg.Canvas.CopyRect(Rect(504,441,576,504),ClipBoardPanel.Canvas, rect(4,4,76,67) );
It works correctly.

However, when the SrcRect & DestRect are calculated as below:
SprSheetImg.Canvas.CopyRect(RectToPaste,ClipBoardPanel.Canvas, RectToCopy);

It does not 'copy' correctly, even though in debugging both tRects hold the correct values?

Any ideas why this may be?
« Last Edit: August 29, 2017, 08:37:25 pm by JasonLugg »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: CopyRect issue?
« Reply #1 on: August 22, 2017, 02:25:07 pm »
that is not possible. If you take in to account that
Code: Pascal  [Select][+][-]
  1.  Rect(504,441,576,504)
is a call to a function that returns a rect that makes it a calculated rect as well. There is no way that the two calls showcased here are equivalent if they do not create the same results.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Re: CopyRect issue?
« Reply #2 on: August 24, 2017, 10:15:12 am »
I get what you are saying and agree about rect(t,l,r,b) calling a function. However when I hard code the numbers in, it works however,when the rects are calculated, i.e CopyRect & PasteRect are filled elsewhere (the values in them are correct as I have debugged them and stepped thru to check the vals) it does  not work?

Code: Pascal  [Select][+][-]
  1.    
  2.  if PopUpPaste.Enabled then
  3.      begin
  4.       //Calculate the rectangle for the paste to space
  5.        RectToPaste:=CalcCurrentSprRect();
  6.  
  7.       //For debugging purposes      Edit6.Text:=inttostr(RectToPaste.Left)+','+inttostr(RectToPaste.Top)+','+inttostr(RectToPaste.Right)+','+inttostr(RectToPaste.Bottom);
  8.        //This WORKS!
  9.        //SprSheetImg.Canvas.CopyRect(Rect(504,441,576,504),ClipBoardPanel.Canvas, rect(4,4,76,67) );
  10.        //THIS DOES NOT?
  11.        SprSheetImg.Canvas.CopyRect(RectToPaste, ClipBoardPanel.Canvas, rect(4,4,76,67) );
  12.        //Explode the pasted image
  13.        ActSizeExploded();
  14.        ActSizeToSpriteSheet(iSpriteNumber);
  15.        SprSheetImg.Refresh;
  16.      end;                

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: CopyRect issue?
« Reply #3 on: August 24, 2017, 01:19:24 pm »
Quote
I get what you are saying and agree about rect(t,l,r,b) calling a function.
Correct order is Left, Top, Right, Bottom. I agree with taazz. It seems to some overlook or something dumb.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Re: [SOLVED] CopyRect issue?
« Reply #4 on: August 29, 2017, 08:38:02 pm »
As mostly is the case...it was my error! Thanks for you help!

 

TinyPortal © 2005-2018