Page 1 of 1

File import picture to image control

Posted: Mon Mar 01, 2021 11:00 pm
by Batninja
Hi, I'm probably missing something obvious but I cannot seem to get a decent image into an image control.

Here is my code

Code: Select all

put "" into image "coverimage" of card "Editor"
   answer file "Select an image (preferably 120dpxx120px)" with tStartDirectory with type ("JPEG Images|jpg,jpeg|JPEG" & return & "PNG Images|png|PNG")
   
   if it <> "" then
      put it into theFilePath
      put URL ("file:" & theFilePath) into image "coverimage"
   else
      --no file was selected, or cancel was pressed
      beep
   end if
It all works but the image is horribly displayed with artefact lines across it. The image control is set to "Resize quality best" and the control size locked. What do I need to do to get a decent image displayed?

Do I need to put the image into a control off-screen or another card and resize it?

Thanks as usual for all help and comments gratefully received.

Re: File import picture to image control

Posted: Tue Mar 02, 2021 9:25 am
by jmburnod
Hi,
You have to use "binfile" instead "file"

Code: Select all

 put URL ("binfile:" & theFilePath) into image "coverimage"
Best regards
Jean-Marc

Re: File import picture to image control

Posted: Tue Mar 02, 2021 10:23 am
by Batninja
Thank you so much Jean-Marc, works perfectly. Love these forums and love Livecode!