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: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Replace pixel color of an image

Post by jmburnod »

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: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Replace pixel color of an image

Post by bn »

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 430 times
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Replace pixel color of an image

Post by dunbarx »

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: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Replace pixel color of an image

Post by dunbarx »

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: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Replace pixel color of an image

Post by jmburnod »

Bernd, Craig,

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

Kind regards

Jean-Marc
https://alternatic.ch
Post Reply