Replace pixel color of an image

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Replace pixel color of an image

Post by jmburnod » Thu Aug 16, 2012 7:31 pm

Hi All,
I need to replace white pixels of an image with blue pixels
Does someone have a useful script to do that ?

Thanks
Jean-Marc
https://alternatic.ch

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Replace pixel color of an image

Post by bn » Thu Aug 16, 2012 8:46 pm

Salut Jean-Marc,

here is a little stack that replaces white pixels with blue pixels. Please look at the explanation and the script of the button.



Kind regards

Bernd
Attachments
replaceWhiteWithBlueInImage.livecode.zip
(181.22 KiB) Downloaded 350 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Replace pixel color of an image

Post by dunbarx » Thu Aug 16, 2012 9:01 pm

Jean-Marc:

Shades of Steve Maller's "ThePixel" XFCN for HC, or Rinaldi's "PixelColor". All from around the Pleistocene.

These returned the value of the pixel under the cursor. But read-only.

And Matthew Reagan wrote a XCMD that would change all the black pixels to any color. close to what you wanted.

It seems impossible that LC does not have a "setPixel" command and "getPixel" function. Could not find one, though.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Replace pixel color of an image

Post by dunbarx » Thu Aug 16, 2012 9:05 pm

Bernd.

Ah. So there is such a tool, even though it requires that the entire imageData be processed. Very cool.

Craig

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Replace pixel color of an image

Post by jmburnod » Thu Aug 16, 2012 9:23 pm

Bernd, Craig,

Thank for your fast reply
I will test the Bernd's stack tomorrow

Kind regards

Jean-Marc
https://alternatic.ch

Post Reply