setting the brushColor to transparent color

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mfstuart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun Apr 09, 2006 9:49 pm
Location: Irvine, CA, USA

setting the brushColor to transparent color

Post by mfstuart » Tue Jul 29, 2008 4:25 pm

Hi all,
I posted this question on the rev-list and got no answer as yet. So here goes.
Can the brushColor have a transparency to it?

eg: in my application, the user can import a snapshot and then with a click of a button, set the tool to a brush and then pick a color (yellow) to hilite part of the imported image. Such as using the Sharpie Highlighter on a printed document.
So the color has to have transparency setting. Otherwise using the brush will just wipe over with the selected yellow.

TIA,
Mark Stuart

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Tue Jul 29, 2008 5:41 pm

Hi Mark,
Can the brushColor have a transparency to it?
To make it short, no it can't.


Best

Klaus

mfstuart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun Apr 09, 2006 9:49 pm
Location: Irvine, CA, USA

re: setting the brushColor to transparent color

Post by mfstuart » Tue Jul 29, 2008 5:59 pm

Ouch!

Danke Klaus.
I'll submit an enhancement request.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Tue Jul 29, 2008 7:41 pm

Hi Mark,

you could probably overlay your snapshot with an empty image of the same size and set the transparency of this image to about 50 to 60. Then your user can hilite the part of the imported image with a yellow 'pen' on your overlay.
Depending on your needs this might work. If you want to preserve the markings you could again take a snapshot?

regards

Bernd

mfstuart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun Apr 09, 2006 9:49 pm
Location: Irvine, CA, USA

Post by mfstuart » Tue Jul 29, 2008 10:42 pm

Bernd,

I did as you suggested, and that worked for me.

On a test stack, I imported an image, added an image object (the overlay), set the Blending level to 60. Manually selected the brush and set the color. "Swiped" over the image and walla - it works, I have transparency on the overlay.

Now to make it work like SnagIt - hold mouse down and drag, creates a square/oblong shape with handles to allow the user to move the overlay and change its shape/dimensions. Cool.

Thanx,
Mark Stuart

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Tue Jul 29, 2008 11:34 pm

Hi Mark,

glad it worked for you.

just in case you want to 'freeze' the changes to the pict and you want to do it with a snapshot you will want to use the global coordinates to reference the area of the first image, since refering to the rect of the first image gives you a snapshot without the overlay.

if you refer to the first image:

Code: Select all

    put the rect of image "NameOfFirstImage" into myRect
    put item 1 to 2 of myRect into tTopLeft
    put item 3 to 4 of myRect into tBottomRight
    put globalloc(tTopLeft) into item 1 to 2 of myRect
    put globalloc(tBottomRight) into item 3 to 4 of myRect
    import snapshot from rect myRect
above code as a reminder (to myself)..., because I ran into this problem

cheers
Bernd

mfstuart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun Apr 09, 2006 9:49 pm
Location: Irvine, CA, USA

Post by mfstuart » Wed Jul 30, 2008 2:27 am

Hi Bernd,

Haven't tried your code as yet, but does it capture the "overlay" as well?

What I would like to do...
Option to "flatten the image" to not only capture the original image, but also the "additions" by the user into the "overlay" image. Basically, this would combine all overlays into one image.

cheers,
Mark Sruart

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Wed Jul 30, 2008 5:25 am

Another solution for 'flattening' your image is to group the two (or more) images and then use the following one-liner:

Code: Select all

export snapshot from group "ImageAndOverlays" to file theFilePath as PNG
Instead of PNG, you can also use JPEG or GIF. If your software has a trial version, you could add a translucent field with white text to the mix in order to watermark the image.

The advantage of this approach is that it's done entirely in Revolution's back-buffer, and a suddenly appearing overlapping window can't interfere with it.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Wed Jul 30, 2008 9:18 am

Hi Mark,

If you take the snapshot from the global coordinates as in the code I posted it "flattens" the image, i.e. takes a snapshot from the original image and the second image with the marks.

Also Jan posted a different approach to flattening the image by grouping them.

BTW you probably could do similar things with graphics on top of your first image, should work just as well and depending on what you want might be a consideration (it would probably easier to implement an undo among other things) just set the opaque of the graphic to false, adjust color
"set the foregroundcolor of graphic "xyz" to red" etc.

regards

mfstuart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun Apr 09, 2006 9:49 pm
Location: Irvine, CA, USA

Post by mfstuart » Thu Jul 31, 2008 10:04 pm

Hi Jan and bn,
Awesome suggestions that I had no idea how to do, so thank you both.
I'm currently in the midst of releasing a new version of our companies software product (CRM) in my day job, so will try your suggestions real soon. And post the results here.

Regards,
Mark Stuart

Post Reply

Return to “Multimedia”