Page 1 of 1
Import paint with mask
Posted: Fri Mar 30, 2012 9:38 am
by doobox
Hi there i wonder where i am going wrong here...
I have :
Code: Select all
import paint from file dragData["files"] with mask specialfolderpath("desktop") & "/exhibit.pbm"
the dragged image in my test is a .jpg 300px x 300px
the mask is a .pbm plain black tile 300px x 300px
So i would have assumed i would get as a result a completely transparent image in my test.
I don't..!
What i get is the image in it's original appearance.
The docs say :
import type from file filePath [with mask maskFilePath]
eg: import paint from file it with mask "/etc/res/oval.pbm"
The maskFilePath specifies the name and location of a one-bit mask file for an image. You can use a mask file only if the file being imported is in the PBM format.
Am i misinterpreting this.. and i actually need the dragged in image file to also be in the .pbm format...?
Mind.. i tried this and it throws an error..!
??
Re: Import paint with mask
Posted: Fri Mar 30, 2012 9:44 am
by doobox
I wonder if my mask is correctly formatted...
I used a copy of contenta converta.. to create this .pbm file...
Link to .pbm file :
http://dl.dropbox.com/u/6308635/exhibit.pbm
Re: Import paint with mask
Posted: Fri Mar 30, 2012 12:17 pm
by Klaus
Hi Gary,
I am sure there is a reason for you to deal with graphics formats from the last century!?
Is there?
No chance you can deal with PNG or GIF files etc.?
Support for exotic formats like XWD, XBM, XPM, PBM, PGM, or PPM is a relict from the ancient days
way before 2000, when MetaCard, the grandpa of LiveCode, was UNIX only.
Best
Klaus
Re: Import paint with mask
Posted: Fri Mar 30, 2012 12:30 pm
by doobox
Hi Klaus,
I have never tried manipulating image data before. What i aim to do is clip out a transparent border of an image.
An example would be the way those ios icon apps work. I had assumed they were masking the rounded corners from the image data. And when i stumbled upon this in the docs :
import paint from file it with mask "/etc/res/oval.pbm"
I thought the black pixels in the oval.pbm mask there would make the pixels of the image in the it variable transparent. (like the way a photoshop vector mask appears to work).
Is there a way to have a black and white image overlay another image as a mask in this fashion..?
I had obviously optimistically thought i had stumbled on a free ride

Re: Import paint with mask
Posted: Fri Mar 30, 2012 12:42 pm
by Klaus
Hi Gary,
you could use some "template" PNG files with the transparency you need in them
and then you could apply that mask to other images like this:
...
set the alphadata of img "the one without ranparency" to the alphadata of img "transparency template1"
...
Done it works fine!
BUT this requires that both images have IDENTICAL dimensions (w/h)!
Check "alphadata" in the dictionary.
EDIT:
I added a tiny demo stack
Best
Klaus
Re: Import paint with mask
Posted: Fri Mar 30, 2012 12:49 pm
by doobox
Thanks Klaus,
That sounds like the job
Mean time i just discovered inks

Christmas has come early.. wow these are great.. i wont get another thing done in the current project today now

Re: Import paint with mask
Posted: Fri Mar 30, 2012 12:52 pm
by Klaus
Check the tiny stack I just added for a quick and dirty example...
Re: Import paint with mask
Posted: Fri Mar 30, 2012 1:00 pm
by doobox
Totally my goal when i started the day.. Thanks a million Klaus.
Re: Import paint with mask
Posted: Fri Mar 30, 2012 1:13 pm
by Klaus
Hi Gary,
my pleasure!
OK, next on my todo list: universal peace...
Best
Klaus
Re: Import paint with mask
Posted: Fri Mar 30, 2012 1:19 pm
by doobox
All sorted for any image size now thanks to you...
Code: Select all
import paint from file dragData["files"]
set the visible of last img to false
put last img into fullSizeImageData -- save the origonal for later
delete last img
put fullSizeImageData into me
rescaleIcon "photoDropZone", 300
setBackgroundFrame
put the width of image "photoDropZone" into tImageWidth
put the height of image "photoDropZone" into tImageHeight
set the width of image "mask" to tImageWidth
set the height of image "mask" to tImageHeight
set the alphadata of img "photoDropZone" to the alphadata of img "mask"
If you need a hand with universal peace, just shout

Re: Import paint with mask
Posted: Fri Mar 30, 2012 3:19 pm
by Klaus
Hi Gary,
doobox wrote:All sorted for any image size now thanks to you...
glad you got it working!
doobox wrote:... If you need a hand with universal peace, just shout

Ah, great, might be the case, thank you
Best
Klaus