imagedata and alpha byte

2018-05-09 Thread Niggemann, Bernd via use-livecode
Correcting my previous post.

You don't have to set the imageData explicitly. I was confused by vanishing 
images.

Apparently if you want to set all of the imageData to numToByte(0) or 
numToByte(256) the image vanishes.

The workaround is to set it to 1 or 255 respectively. This is in LC 9 GM

Kind regards
Bernd

Here is the corrected script

---
on mouseUp
   local tAlphaData, tTransparent, tOpaque
   local tCollect, tLength
   
   -- not needed here but if you want to modify existing AD
   put the alphaData of image 1 into tAlphaData
   
   put numToByte(1) into tTransparent -- dont set to 0 or image vanishes
   put numToByte(255) into tOpaque -- dont set to 256 or image vanishes
   put the width of image 1 * the height of image 1 into tLength
   
   repeat tLength
  --put tTransparent after tCollect
  put tOpaque after tCollect
   end repeat
   
   set the alphaData of image 1 to tCollect
end mouseUp
-
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: imagedata and alpha byte

2018-05-09 Thread Niggemann, Bernd via use-livecode
Hi,

please do not use numToChar in version 7.0 and up for image manipulation, use 
numToByte or byteToNum

NumToChar is deprecated. It might work but is horribly slow.

along the lines of Mike's example

--
on mouseUp
   local tAlphaData, tTransparent, tHalfTransparent
   local tImgData, tCollect, tLength
   
   put the imageData of image 1 into tImgData
   
   -- not needed here but if you want to modify existing AD
   put the alphaData of image 1 into tAlphaData
   
   put numToByte(0) into tTransparent
   put numToByte(127) into tHalfTransparent
   put the width of image 1 * the height of image 1 into tLength
   
   repeat tLength
  -- put tTransparent after tCollect
  put tHalfTransparent after tCollect
   end repeat
   
   -- in LC 9 you have to set imagedata again explicitly
   set the imageData of image 1 to tImgData
   
   set the alphaData of image 1 to tCollect
end mouseUp


Kind regards
Bernd



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: imagedata and alpha byte

2018-05-09 Thread Mike Bonner via use-livecode
Already assuming that you know which pixel you wish to modify, (like if you
want to modify pixel 25 in pixel row 3, that would be pixel 75.. I
think..)  you would need to do something like the following..

--first, put the current alphadata into a variable.
put the alphadata of img "myImg" into tAlpha

-- then modify the alphadata for the pixel in question
put numtochar(0) into char 75  of tAlpha -- 0 is transparent, 255 is
completely opaque
-- change all necessary pixels here then
-- set the image to the new alphadata
set the alphadata of img "myImg" to tAlpha

On Wed, May 9, 2018 at 11:59 AM, jbv via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On Wed, May 9, 2018 7:51 pm, Richmond Mathewson via use-livecode wrote:
> > The inevitable question has to be why you are doing that in such a
> > fiddly sort of way.
> >
> > Richmond.
> >
>
> It would be too long to explain, but in short some users of a client
> app will modify pixels of images that will then be exported as PNG to
> a server and then displayed in a website.
> I have successfully modified the alpha channel of images with php for
> years, and am just wondering why this doesn't work in LC...
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: imagedata and alpha byte

2018-05-09 Thread jbv via use-livecode
On Wed, May 9, 2018 7:51 pm, Richmond Mathewson via use-livecode wrote:
> The inevitable question has to be why you are doing that in such a
> fiddly sort of way.
>
> Richmond.
>

It would be too long to explain, but in short some users of a client
app will modify pixels of images that will then be exported as PNG to
a server and then displayed in a website.
I have successfully modified the alpha channel of images with php for
years, and am just wondering why this doesn't work in LC...


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: imagedata and alpha byte

2018-05-09 Thread Richmond Mathewson via use-livecode
The inevitable question has to be why you are doing that in such a 
fiddly sort of way.


Richmond.

On 9/5/2018 8:49 pm, jbv via use-livecode wrote:

Hi list,
Still struggling with imagedata, I am trying to modify the transparency
of an image by manipulating pixel by pixel the alpha byte.
I tried with numToChar(0) and binaryEncode("B*","") but to no
avail...
OTOH manipulating the RVB channel works fine.

Any idea on how modify the alpha channel of the imagedata of a image,
and then exporting the image as PNG with the modified transparency ?

Thanks in advance.
jbv


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


imagedata and alpha byte

2018-05-09 Thread jbv via use-livecode
Hi list,
Still struggling with imagedata, I am trying to modify the transparency
of an image by manipulating pixel by pixel the alpha byte.
I tried with numToChar(0) and binaryEncode("B*","") but to no
avail...
OTOH manipulating the RVB channel works fine.

Any idea on how modify the alpha channel of the imagedata of a image,
and then exporting the image as PNG with the modified transparency ?

Thanks in advance.
jbv


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode