Page 1 of 1
Drag drop image white is removed
Posted: Thu Aug 16, 2012 1:51 pm
by doobox
Hi there,
I don't have any alphaData related code in my script. But my image dropzone systematically removes plain white from any image dragged in.
See screen shot here :
https://skitch.com/doobox/ec91y/rapid-icons
Here is the part of the handler that produces that image when it is dropped :
Code: Select all
on dragDrop
set the itemDelimiter to "."
// only allow files of type below
put "jpeg.jpg.png.bmp.tiff.tif" into tAllowedFiles
if the last item of dragData["files"] is among the items of tAllowedFiles then
import paint from file dragData["files"]
set the visible of last img to false
put last img into fullSizeImageData -- save the origonal for later
put the width of the last image into tOrigonalImageWidth
put the height of the last image into tOrigonalImageHeight
if tOrigonalImageWidth < 57 or tOrigonalImageHeight < 57 then
answer "Images must be greater than 56px x 56px" with "OK" as sheet
exit dragDrop
end if
delete last img
put fullSizeImageData into me
// 200 for show
if tOrigonalImageWidth < 200 or tOrigonalImageHeight < 200 then
if tOrigonalImageWidth < tOrigonalImageHeight then
rescaleIcon "photoDropZone", tOrigonalImageWidth
else
rescaleIcon "photoDropZone", tOrigonalImageHeight
end if
else
rescaleIcon "photoDropZone", 200
end if
rescaleIcon "photoDropZone", 200
crop img "photoDropZone" to the rect of graphic "photoMountBG"
set the visible of image "dropHint" to false
set the imagedata of image "photoDropZone" to the imagedata of image "photoDropZone"
put image "photoDropZone" into tCroppedImage
Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 2:03 pm
by Klaus
Hi Gary,
what format are the images in question in?
JPG, GIF, PNG, PICT, BMP?
Obviously WHITE is defined as TRANSPARENT in the image(s).
If this is true, then you cannot do much about this but use another format WITHOUT transparency like JPG.
Best
Klaus
Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 2:14 pm
by doobox
The ones i have used randomly in testing that show the issue are png's,
So you think when i created the images, my image software has added information to the image that defines white as transparent..?
If this is the case i guess this could be the same on images that anyone using the app has.
So i will need to do something to overcome this.
Problem is if someone drops a png that is meant to have transparency, i want to preserve that.
So i cant really clone the image dropped into a jpg in some way.
or
loop through the pixels looking for transparent ones and replacing them with white..
problem for sure....!
Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 2:32 pm
by Klaus
Hi Gary,
if these images do also appear this way in the IDE you cannot do much about this.
Cycling through all pixels and correct might be just too slow in LiveCode.
The images and the "transpareny" do also appear so jaggy!?
Is this an 8 bit PNG file?
Best
Klaus
Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 2:44 pm
by doobox
Further investigating reveals there is definetely something wrong with my code.
As another app i built a while ago and ripped the code from, works properly with the same images.
Something in this new stack is treating white as transparent during that darg and drop handler.
I will investigate a little further, comparing the code from both apps in the drag handler.
I just wonder if i have somehow switched on some kind of global in this stack that treats solid white as transparent during paint from file.
compare the two screens below using same image :
my old app:
https://skitch.com/doobox/ec949/icon-developer
my new app:
https://skitch.com/doobox/ec94s/rapid-icons
As i ripped the dragdrop handler from the old app i cant understand why i am seeing different results at this point.
Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 3:21 pm
by Klaus
Hint: TIFF files are not supported by LiveCode!
Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 3:33 pm
by doobox
I seem to have fixed the issue.. I must have corrupt the actual image control somehow.
I replaced the image control and copied the code exactly from the old control over.
I worked right off the bat.
I am yet to work out what i could have set in the old image control that could have caused the white to be stripped as it was being.
I will remove tiff from my list of options

Re: Drag drop image white is removed
Posted: Thu Aug 16, 2012 9:14 pm
by doobox
Ironed the issues out and released the new app earlier.
Thought you guy's might like to see what i was up-to
Showcase website :
http://www.garysimpson.co.uk/rapidicons/
Re: Drag drop image white is removed
Posted: Fri Aug 17, 2012 12:54 pm
by Klaus
Hi Gary,
great you got it working!
Yes, I also experiencwed "corrup" objects in LiveCode.
It is VERY rare, but happens from time to time.
I had a bad field and even a player object,
simply replacing with an exact copy resolved this.
Best
Klaus
Re: Drag drop image white is removed
Posted: Fri Aug 17, 2012 1:16 pm
by doobox
Just on the off chance Klaus...
Is there anything regarding the way i am now handling drag to finder, that you can think of that would not work in Snow Leopard..?
I released my app yesterday but had to drop the min system requirement to 10.7.0 because i got immediate reports that the icon was not able to be dragged out in Snow Leopard.
I don't do exactly what you showed, but more or less.. I kinda fool the user into thinking there dragging a favicon.ico file, but there really dragging an image. and when the image is dropped
the dragData has actually been set to the favicon.ico file i created moments ago.
Code: Select all
on dragstart
set the dragaction to "copy"
set the dragImage to the id of me
put specialfolderpath("Temporary") & "/favicon.ico" into tTempImage
set the dragdata["files"] to tTempImage
end dragstart
If there is nothing related to the writing to the temp folder that you can think of that would not work in snow leopard. Then there must be an issue creating the icon in snow leopard, and the file is not actually there on dragStart (above).
I create the favicon.ico when the user image is dropped in with the command line tool "iconutil -c icns -o <icon filename> <iconset filename>" have just created an iconset folder containing the appropriately sized and named png's from the origonal the user just dropped.
Code: Select all
## make favicon folder
lock screen
create folder specialfolderpath("Temporary") & "/favicon.iconset/"
put tCroppedImage into image "temp32"
rescaleIcon "temp32", 32
set the imagedata of image "temp32" to the imagedata of image "temp32"
put specialfolderpath("Temporary") & "/favicon.iconset/icon_32x32.png" into tTempImage
put the text of image "temp32" into url("binfile:" & tTempImage)
put tCroppedImage into image "temp16"
set the width of image "temp16" to 16
set the height of image "temp16" to 16
set the imagedata of image "temp16" to the imagedata of image "temp16"
put specialfolderpath("Temporary") & "/favicon.iconset/icon_16x16.png" into tTempImage
put the text of image "temp16" into url("binfile:" & tTempImage)
unlock screen
## run the terminal
put specialfolderpath("Temporary") into tTempFilePath
put specialfolderpath("Temporary") & "/favicon.ico" into tTempOutputPath
get shell("cd" && tTempFilePath && "; iconutil -c icns -o " & tTempOutputPath & " favicon.iconset")
## answer it with "OK" as sheet
Maybe this is the point its failing in snow leopard but i cant imagine why, just snow leopard.
Re: Drag drop image white is removed
Posted: Fri Aug 17, 2012 2:42 pm
by Klaus
Hi Gary,
no idea...
But why are you using "favico.ico" as filename?
"iconutil" will of course only convert to the Mac ics or icns file format,
and for Mac users "favico.ico" might be a bit ermm... unusual
Best
Klaus
Re: Drag drop image white is removed
Posted: Fri Aug 17, 2012 2:58 pm
by doobox
Turns out iconutil was not available in snow leopard. (hence the issue)
But the app is aimed at Rapidweaver users primarily. And each Rapidweaver project requires you drop in a favicon.ico and a web clip icon.
Using iconutil and telling it to output the file as favicon.ico containing 16px and 32px images works though and is correctly displayed in the browser.
Re: Drag drop image white is removed
Posted: Fri Aug 17, 2012 3:47 pm
by Klaus
Ah,OK, I see!
Thanks for the info.