Page 1 of 1

Strange cropping behavior

Posted: Wed Mar 13, 2019 4:14 pm
by giovanni_c
Hi everybody,
just want to ask you here if you are experiencing problems in cropping images.
My current experience in 9.0.x is that cropping an image will result in an image resizing instead of a proper cropping.
You can find attached to the post a stack in 3 different versions (7.0, 5.5 and 2.7).
The button in the stack will copy an image (PNG with transparency) on another image and will crop it at half height. In LC 9.x, 8.x, 7.x and 6.x I was able to try this operation will result in a resize, not crop. In an old LC 5.0.2 this will result in a proper cropping (this is why I loaded the stack in different version formats)

On an application, ported from an older version of LC to the latest one, I also noticed that the crop operation corrupt my PNGs, alterating the transparency and colours. Unfortunately I'm not able to replicate it on a new stack...

Can you help me to understand what's going on?
Thank you very much

Re: Strange cropping behavior

Posted: Wed Mar 13, 2019 4:40 pm
by Klaus
Buongiorno Giovanni,

not sure, but since you use an already scaled down image, this may cause the cropping to fail!?
If I use an image 1:1, everything looks like it should, and that means a correct cropped image, too.
See attached screen, please try it yourself!

Image on the left = 1:1 and the cropped doublette is also correct:
Bildschirmfoto 2019-03-13 um 16.38.10.jpg

Re: Strange cropping behavior

Posted: Wed Mar 13, 2019 5:38 pm
by jmburnod
Hi Klaus,
I get an other result (LC 9.01)
Best
Jean-Marc

Re: Strange cropping behavior

Posted: Wed Mar 13, 2019 5:52 pm
by Klaus
Yes, same here. 8)
But my screen shows an UNscaled image before and after cropping!
Looks like this (cropping an already scaled image) does in fact affect cropping.

Re: Strange cropping behavior

Posted: Wed Mar 13, 2019 7:11 pm
by giovanni_c
Hi Klaus and jmburnod, first of all thank you for your replies.
Working on non-resized image actually change the behavior but in any case I have weird result (I.E. different resulting cropped image if I use breakpoints or not...).
Also I can see that if I crop the non-resized image and it's cropped properly, if I resize it back to the size that I need I have again wrong resulting image...

I think that this is a bug in the engine and I think that I will go to report it after other kind of investigation.
Have you got any suggestion about this?

Re: Strange cropping behavior

Posted: Wed Mar 13, 2019 7:25 pm
by Klaus
Hi Giovanni,

yep, create a bug-report here:
https://quality.livecode.com


Best

Klaus

Re: Strange cropping behavior

Posted: Thu Mar 14, 2019 9:27 am
by giovanni_c
Hi Klaus,
I filed a new bugreport:

https://quality.livecode.com/show_bug.cgi?id=21895

Thank you for your help and suggestions.

Re: Strange cropping behavior

Posted: Sat Mar 16, 2019 11:44 am
by [-hh]
You could try the following (cropping for scaled images):

Code: Select all

on mouseUp
  lock messages; lock screen
  if there is no img "bDup" then create img "bDup"
  put img "background" into img "bDup"
  put the rect of grc "destRect" into tR
  set the rect of img "bDup" to tR
  #-- set unscaled imagedata
  set the imageData of img "bDup" to the imagedata of img "bDup"
  #--
  subtract (item 4 of tR-item 2 of tR) div 2 from item 4 of tR
  crop img "bDup" to tR
  unlock screen; unlock messages
end mouseUp