Load images at proportional size

11 messages Options
Embed this post
Permalink
JosepM

Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Hi,

I need to load at proportional size images inside the image area, but the image area have her own size. How can fit the image inside the image area changing her width and height?

I'm blocked... :(

Any idea? I search the list but I can't found any...

Salut,
Josep
Mark Schonewille-3

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Hi Josep,

function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
   if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
     put theCdWidth / theImgWidth into myRatio
   else
     put theCdHeight / theImgHeight into myRatio
   end if
   put theImgWidth * myRatio into myNewWidth
   put theImgHeight * myRatio into myNewHeight
   return myNewWidth,myNewHeight
end rescale

example:

lock screen
put rescale(<width of image>,<height of image>,<width of image  
area>,<height of image area>) into myNewSize
set the width of img x to item 1 of myNewSize
set the height of img x to item 2 of myNewSize
set the loc of img x to <loc of image area>
unlock screen

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.






On 5 jul 2009, at 10:03, Josep wrote:

>
> Hi,
>
> I need to load at proportional size images inside the image area,  
> but the
> image area have her own size. How can fit the image inside the image  
> area
> changing her width and height?
>
> I'm blocked... :(
>
> Any idea? I search the list but I can't found any...
>
> Salut,
> Josep
> --
> View this message in context: http://www.nabble.com/Load-images-at-proportional-size-tp24340945p24340945.html
> Sent from the Revolution - User mailing list archive at Nabble.com.

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Sarah Reichelt-2

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
In reply to this post by JosepM
> I need to load at proportional size images inside the image area, but the
> image area have her own size. How can fit the image inside the image area
> changing her width and height?

If you get the formattedHeight of the image and the formattedWidth of
the image, that tells you the original number of pixels.
If you pick a fixed height or a fixed width for the display image, you
can calculate what the other dimension should be and set the size of
the image object accordingly.
Make sure you set the lockLoc of the image to true or it will resize
to the full dimensions of the image when the stack is opened.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Mark Schonewille-3

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Hmmm.... yes, Josep might want to use my function with formattedHeight  
and formattedWidth rather than regular height and width.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.




On 5 jul 2009, at 10:21, Sarah Reichelt wrote:

>
> If you get the formattedHeight of the image and the formattedWidth of
> the image, that tells you the original number of pixels.
> If you pick a fixed height or a fixed width for the display image, you
> can calculate what the other dimension should be and set the size of
> the image object accordingly.
> Make sure you set the lockLoc of the image to true or it will resize
> to the full dimensions of the image when the stack is opened.
>
> Cheers,
> Sarah


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
JosepM

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Thanks Mark,... works fine...

But now I detecting some extrange issue. When Drag from the desktop or the web page sometime the source image have height and width = 0... I don't know why, some times drag and drop perfectly and sometime no, and Rev crash!

Code:

on dragDrop
   lock screen
   set the width of me to 210
   set the height of me to 295
   set the threeD of me to true
   set itemdel to "/"
   put the last item of the dragdata into fld lbl_filename
   
   put URL the dragData into me
   put rescale( the formattedwidth of me,the formattedheight of me,the width of me,the height of me) into myNewSize
   set itemdel to comma
   set the width of me to item 1 of myNewSize
   set the height of me to item 2 of myNewSize
   unlock screen
end dragDrop

I set the width and height at the begin to put the original size, so if the image is rescaled to a small size the next time the image have these size.

Any idea?

Salut,
Josep

Mark Schonewille-3 wrote:
Hmmm.... yes, Josep might want to use my function with formattedHeight  
and formattedWidth rather than regular height and width.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.




On 5 jul 2009, at 10:21, Sarah Reichelt wrote:
>
> If you get the formattedHeight of the image and the formattedWidth of
> the image, that tells you the original number of pixels.
> If you pick a fixed height or a fixed width for the display image, you
> can calculate what the other dimension should be and set the size of
> the image object accordingly.
> Make sure you set the lockLoc of the image to true or it will resize
> to the full dimensions of the image when the stack is opened.
>
> Cheers,
> Sarah


_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Mark Schonewille-3

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Josep,

The crash is indeed a very big problem with D&D. It is very  
frustrating that this hasn't been fixed yet. The following might help.  
First, get the dragdata and then give Revolution time to deal with it  
by itself. The send command will execute the remainder of your script  
after Revolution has done it's thing.

local lbl_filename
on dragDrop
   put the last item of the dragdata into fld lbl_filename
   send "doDDstuff" to me in 0 millisecs
end dragDrop

on doDDstuff
   -- do everything else here
end doDDstuff

Please, let me know whether this avoids the crash.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.


On 6 jul 2009, at 02:05, Josep wrote:

>
> Thanks Mark,... works fine...
>
> But now I detecting some extrange issue. When Drag from the desktop  
> or the
> web page sometime the source image have height and width = 0... I  
> don't know
> why, some times drag and drop perfectly and sometime no, and Rev  
> crash!
>
> Code:
>
> on dragDrop
>   lock screen
>   set the width of me to 210
>   set the height of me to 295
>   set the threeD of me to true
>   set itemdel to "/"
>   put the last item of the dragdata into fld lbl_filename
>
>   put URL the dragData into me
>   put rescale( the formattedwidth of me,the formattedheight of  
> me,the width
> of me,the height of me) into myNewSize
>   set itemdel to comma
>   set the width of me to item 1 of myNewSize
>   set the height of me to item 2 of myNewSize
>   unlock screen
> end dragDrop
>
> I set the width and height at the begin to put the original size, so  
> if the
> image is rescaled to a small size the next time the image have these  
> size.
>
> Any idea?
>
> Salut,
> Josep
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
JosepM

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Hi Mark,

Before test your new code I restart Rev and begin again checking all.
If I drag from the website all is fine while (of course) the image have the correct path to get from the URL.
Mant images are referenced by CSS or others and doesn't work, so I drag into the desktop. Until here all fine. In the desktop I can see the size of the draged image, open it, etc...
But if try to drag these image from the desktop to the stack or open it via:

on mouseUp
   answer file "Choose image file"
   put it into tfile  
   put URL tfile into img img_card
end mouseUp

Doesn't work. The formattedWidth and formattedHeight are 0, so one divide by zero is raising and crash Rev.

Any idea?  :(
Mark Schonewille-3

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Hi Josep,

My "idea" is what I posted a few minutes ago. Apart from that, if you  
have any repeat loops or wait commands with messages running (or  
waiting), this might also cause a crash if you drag from the desktop  
at the same time. If you could avoid running repeat loops and wait  
command simultaneously with dragging-and-dropping, you might  
experience less crashes.

I suspect that Revolution doesn't respond correctly to a few requests  
from the Finder, after which the operating system decides that  
Revolution has crashed, but this is sheer speculation as I don't know  
any technical details regarding this.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.



On 6 jul 2009, at 02:40, Josep wrote:

>
> Hi Mark,
>
> Before test your new code I restart Rev and begin again checking all.
> If I drag from the website all is fine while (of course) the image  
> have the
> correct path to get from the URL.
> Mant images are referenced by CSS or others and doesn't work, so I  
> drag into
> the desktop. Until here all fine. In the desktop I can see the size  
> of the
> draged image, open it, etc...
> But if try to drag these image from the desktop to the stack or open  
> it via:
>
> on mouseUp
>   answer file "Choose image file"
>   put it into tfile
>   put URL tfile into img img_card
> end mouseUp
>
> Doesn't work. The formattedWidth and formattedHeight are 0, so one  
> divide by
> zero is raising and crash Rev.
>
> Any idea?  :(
> --
> View this message in context: http://www.nabble.com/Load-images-at-proportional-size-tp24340945p24348270.html
> Sent from the Revolution - User mailing list archive at Nabble.com.

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Brian Yennie

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
In reply to this post by JosepM
Josep,

Does either of these work better for you?

set the fileName of img img_card to tURL

OR

put url ("binfile:" & tURL) into img img_card

>
> Hi Mark,
>
> Before test your new code I restart Rev and begin again checking all.
> If I drag from the website all is fine while (of course) the image  
> have the
> correct path to get from the URL.
> Mant images are referenced by CSS or others and doesn't work, so I  
> drag into
> the desktop. Until here all fine. In the desktop I can see the size  
> of the
> draged image, open it, etc...
> But if try to drag these image from the desktop to the stack or open  
> it via:
>
> on mouseUp
>  answer file "Choose image file"
>  put it into tfile
>  put URL tfile into img img_card
> end mouseUp
>
> Doesn't work. The formattedWidth and formattedHeight are 0, so one  
> divide by
> zero is raising and crash Rev.
>
> Any idea?  :(
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
JosepM

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Hi,

set the fileName of me to the dragData --> Run both from website and desktop Drag&Drop

put URL the dragData into me --> Work only from website Drag&Drop.

put url ("binfile:" & the dragData) into me --> Work only from desktop Drag&Drop.


Very extrange issue, almost for me. Now is working and I need test more...

Why this happen? Isn't the same three sentences work for the same?

How can I identify the type of object or data that is being dragged? For the file extension directly?

Salut,
Josep M


Josep,

Does either of these work better for you?

set the fileName of img img_card to tURL

OR

put url ("binfile:" & tURL) into img img_card

Brian Yennie

Re: Load images at proportional size

Reply Threaded More More options
Print post
Permalink
Josep,

I think the key here is that remote files are loaded as binary by  
default, whereas local files are text by default. Thus I think you  
need to look at the URL, and if it is a local file, then make sure the  
protocol is binfile.

Filename property works regardless because images will always assume  
binary. The URL syntax is going to load the data before it knows where  
it is going.

Hope that helps.

>
> Hi,
>
> set the fileName of me to the dragData --> Run both from website and  
> desktop
> Drag&Drop
>
> put URL the dragData into me --> Work only from website Drag&Drop.
>
> put url ("binfile:" & the dragData) into me --> Work only from desktop
> Drag&Drop.
>
>
> Very extrange issue, almost for me. Now is working and I need test  
> more...
>
> Why this happen? Isn't the same three sentences work for the same?
>
> Salut,
> Josep M
>
>
> Josep,
>
> Does either of these work better for you?
>
> set the fileName of img img_card to tURL
>
> OR
>
> put url ("binfile:" & tURL) into img img_card
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution