Convert transparent PNG on import?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert transparent PNG on import?

Marty Knapp-2
Is there a way to convert a transparent PNG graphic to non-transparent
when importing? There are 2 bugs on Windows (Mac is OK) when printing
transparent images (any image with transparency or any image given
transparency via blendLevel or inks. They are bugs 14089 and 14256 -
both confirmed. They happen when printing and when using the LC print to
PDF feature.

At this point I'm limiting my users to importing only Jpegs or BMPs but
that is pretty lame. I've also disabled the image fading control I have
on my Windows version. Certainly I can tell users to not use transparent
PNGs but you know someone will and if they do it may cause them a lot of
grief.

Alternately, is there a way to detect if an imported PNG has
transparency? If so, then I could disallow just those.

Thanks,
Marty K

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

Richmond Mathewson-2
On 02/02/15 20:27, Marty Knapp wrote:

> Is there a way to convert a transparent PNG graphic to non-transparent
> when importing? There are 2 bugs on Windows (Mac is OK) when printing
> transparent images (any image with transparency or any image given
> transparency via blendLevel or inks. They are bugs 14089 and 14256 -
> both confirmed. They happen when printing and when using the LC print
> to PDF feature.
>
> At this point I'm limiting my users to importing only Jpegs or BMPs
> but that is pretty lame. I've also disabled the image fading control I
> have on my Windows version. Certainly I can tell users to not use
> transparent PNGs but you know someone will and if they do it may cause
> them a lot of grief.
>
> Alternately, is there a way to detect if an imported PNG has
> transparency? If so, then I could disallow just those.
>
> Thanks,
> Marty K
>

How about this:

when you import an image you then layer it on top of an opaque graphic
of the same size, group the image and the graphic,
do an:

import snapshot from group "My Grouped IMG and GRAPHIC", delete the
imported image and the white graphic,
and you will have any images that contain transparent areas converted to
images with white areas instead.

You will not have to fuss about working out whether your imported images
contain transparent areas or not
as you will perform this process for ALL imported images.

Richmond.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

ScottR
In reply to this post by Marty Knapp-2
Do your users go through an import process?  If yes, and you can determine which images are PNGs (by file suffix for example), then you might be able to replace the contents of the imported PNG with a snapshot of its position on the card.  Export a snapshot of the card using the PNGs rect to a variable, and then set the text of the imported image to the variable.

If you don’t want to mess with the original PNG, you could import a snapshot on top of the original image before printing, and delete any generated snapshots after printing.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design

On Feb 2, 2015, at 10:27 AM, Marty Knapp <[hidden email]> wrote:

> Is there a way to convert a transparent PNG graphic to non-transparent when importing? There are 2 bugs on Windows (Mac is OK) when printing transparent images (any image with transparency or any image given transparency via blendLevel or inks. They are bugs 14089 and 14256 - both confirmed. They happen when printing and when using the LC print to PDF feature.
>
> At this point I'm limiting my users to importing only Jpegs or BMPs but that is pretty lame. I've also disabled the image fading control I have on my Windows version. Certainly I can tell users to not use transparent PNGs but you know someone will and if they do it may cause them a lot of grief.
>
> Alternately, is there a way to detect if an imported PNG has transparency? If so, then I could disallow just those.
>
> Thanks,
> Marty K
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

J. Landman Gay
On 2/2/2015 12:56 PM, Scott Rossi wrote:
> Do your users go through an import process?  If yes, and you can
> determine which images are PNGs (by file suffix for example), then
> you might be able to replace the contents of the imported PNG with a
> snapshot of its position on the card.  Export a snapshot of the card
> using the PNGs rect to a variable, and then set the text of the
> imported image to the variable.

Could you do something with the alpha channel instead? Like, set it to
empty?

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

ScottR
That’s an interesting idea, but I don’t think it will work in many cases because the translucent portions of an image still need to be blended against something.  Just removing the alphaData gets rid of the blending, and for example, will make the soft edge of a an antialiased curve jagged.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design

On Feb 2, 2015, at 11:39 AM, J. Landman Gay <[hidden email]> wrote:

> On 2/2/2015 12:56 PM, Scott Rossi wrote:
>> Do your users go through an import process?  If yes, and you can
>> determine which images are PNGs (by file suffix for example), then
>> you might be able to replace the contents of the imported PNG with a
>> snapshot of its position on the card.  Export a snapshot of the card
>> using the PNGs rect to a variable, and then set the text of the
>> imported image to the variable.
>
> Could you do something with the alpha channel instead? Like, set it to empty?
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

J. Landman Gay
After I posted, it also occured to me that not all transparent images
use white as the alphadata color. So without transparency, you might end
up with a purple or orange image you didn't expect. Hadn't thought of
that. So yeah, probably wouldn't work on a couple of levels.


On 2/2/2015 2:15 PM, Scott Rossi wrote:

> That’s an interesting idea, but I don’t think it will work in many cases because the translucent portions of an image still need to be blended against something.  Just removing the alphaData gets rid of the blending, and for example, will make the soft edge of a an antialiased curve jagged.
>
> Regards,
>
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
>
> On Feb 2, 2015, at 11:39 AM, J. Landman Gay <[hidden email]> wrote:
>
>> On 2/2/2015 12:56 PM, Scott Rossi wrote:
>>> Do your users go through an import process?  If yes, and you can
>>> determine which images are PNGs (by file suffix for example), then
>>> you might be able to replace the contents of the imported PNG with a
>>> snapshot of its position on the card.  Export a snapshot of the card
>>> using the PNGs rect to a variable, and then set the text of the
>>> imported image to the variable.
>>
>> Could you do something with the alpha channel instead? Like, set it to empty?
>>
>> --
>> Jacqueline Landman Gay         |     [hidden email]
>> HyperActive Software           |     http://www.hyperactivesw.com
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

Marty Knapp-2
I had hoped for an on-the-fly remedy to this like Jacque suggested, but
it sounds like I'll have to go with something along the lines of what
Richmond and Scott have suggested. Thanks everyone. Better yet would be
the bug getting fixed! It would be nice if there was a way to know if
the bugs you've reported were going to be addressed or not . . .

Marty K

> After I posted, it also occured to me that not all transparent images
> use white as the alphadata color. So without transparency, you might
> end up with a purple or orange image you didn't expect. Hadn't thought
> of that. So yeah, probably wouldn't work on a couple of levels.
>
>
> On 2/2/2015 2:15 PM, Scott Rossi wrote:
>> That’s an interesting idea, but I don’t think it will work in many
>> cases because the translucent portions of an image still need to be
>> blended against something.  Just removing the alphaData gets rid of
>> the blending, and for example, will make the soft edge of a an
>> antialiased curve jagged.
>>
>> Regards,
>>
>> Scott Rossi
>> Creative Director
>> Tactile Media, UX/UI Design
>>
>> On Feb 2, 2015, at 11:39 AM, J. Landman Gay
>> <[hidden email]> wrote:
>>
>>> On 2/2/2015 12:56 PM, Scott Rossi wrote:
>>>> Do your users go through an import process?  If yes, and you can
>>>> determine which images are PNGs (by file suffix for example), then
>>>> you might be able to replace the contents of the imported PNG with a
>>>> snapshot of its position on the card.  Export a snapshot of the card
>>>> using the PNGs rect to a variable, and then set the text of the
>>>> imported image to the variable.
>>>
>>> Could you do something with the alpha channel instead? Like, set it
>>> to empty?
>>>
>>> --
>>> Jacqueline Landman Gay         |     [hidden email]
>>> HyperActive Software           | http://www.hyperactivesw.com
>>>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

BNig
Hi Marty,

would it help if the transparent parts where just a little non-transparent?
hardly noticeble

You would set all 0 to 1 in alphaData, the rest is unchanged.

-------------------------------------------
on mouseUp
   put the alphaData of image 1 into tAlpha
   put numToByte(0) into tNull
   put numToByte(1) into tOne
   repeat for each byte anAlpha in tAlpha
      if anAlpha = tNull then
         put tOne after tCollect
      else
         put anAlpha after tCollect
      end if
   end repeat
   set the alphaData of image 1 to tCollect
end mouseUp
---------------------------------------------

this is fairly fast, works also in 7.x.x

Once you change 0 to 1 in alphaData the translucent parts of the png receive mouseClicks etc. You must be aware of that.

Kind regards
Bernd
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

Richmond Mathewson-2
On 03/02/15 10:37, BNig wrote:

> Hi Marty,
>
> would it help if the transparent parts where just a little non-transparent?
> hardly noticeble
>
> You would set all 0 to 1 in alphaData, the rest is unchanged.
>
> -------------------------------------------
> on mouseUp
>     put the alphaData of image 1 into tAlpha
>     put numToByte(0) into tNull
>     put numToByte(1) into tOne
>     repeat for each byte anAlpha in tAlpha
>        if anAlpha = tNull then
>           put tOne after tCollect
>        else
>           put anAlpha after tCollect
>        end if
>     end repeat
>     set the alphaData of image 1 to tCollect
> end mouseUp
> ---------------------------------------------
>
> this is fairly fast, works also in 7.x.x
>
> Once you change 0 to 1 in alphaData the translucent parts of the png receive
> mouseClicks etc. You must be aware of that.
>
> Kind regards
> Bernd
>
>

This idea seems very good indeed: the fact that the areas set at 1 in
alphaData will recieve
mouseClicks is no worse than my suggestion about layering with an opaque
graphic, but those
transparent areas will still appear transparent to the end-user, while
with my suggestion
they would have ended up as white.

Richmond.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

Mike Bonner
Using an opaque graphic, with the blendlevel set to 100 works fine, or so
it seems.

On Tue, Feb 3, 2015 at 3:33 AM, Richmond <[hidden email]>
wrote:

> On 03/02/15 10:37, BNig wrote:
>
>> Hi Marty,
>>
>> would it help if the transparent parts where just a little
>> non-transparent?
>> hardly noticeble
>>
>> You would set all 0 to 1 in alphaData, the rest is unchanged.
>>
>> -------------------------------------------
>> on mouseUp
>>     put the alphaData of image 1 into tAlpha
>>     put numToByte(0) into tNull
>>     put numToByte(1) into tOne
>>     repeat for each byte anAlpha in tAlpha
>>        if anAlpha = tNull then
>>           put tOne after tCollect
>>        else
>>           put anAlpha after tCollect
>>        end if
>>     end repeat
>>     set the alphaData of image 1 to tCollect
>> end mouseUp
>> ---------------------------------------------
>>
>> this is fairly fast, works also in 7.x.x
>>
>> Once you change 0 to 1 in alphaData the translucent parts of the png
>> receive
>> mouseClicks etc. You must be aware of that.
>>
>> Kind regards
>> Bernd
>>
>>
>>
> This idea seems very good indeed: the fact that the areas set at 1 in
> alphaData will recieve
> mouseClicks is no worse than my suggestion about layering with an opaque
> graphic, but those
> transparent areas will still appear transparent to the end-user, while
> with my suggestion
> they would have ended up as white.
>
> Richmond.
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

Marty Knapp-2
In reply to this post by BNig
Thank Bernd, I'll give that a try. Detecting mouseClicks or other mouse
related functions aren't an issue for me in this case - it's that
printing images with transparency on Windows can really come out strange
and in some cases cause printing to fail.

Marty K

> Hi Marty,
>
> would it help if the transparent parts where just a little non-transparent?
> hardly noticeble
>
> You would set all 0 to 1 in alphaData, the rest is unchanged.
>
> -------------------------------------------
> on mouseUp
>     put the alphaData of image 1 into tAlpha
>     put numToByte(0) into tNull
>     put numToByte(1) into tOne
>     repeat for each byte anAlpha in tAlpha
>        if anAlpha = tNull then
>           put tOne after tCollect
>        else
>           put anAlpha after tCollect
>        end if
>     end repeat
>     set the alphaData of image 1 to tCollect
> end mouseUp
> ---------------------------------------------
>
> this is fairly fast, works also in 7.x.x
>
> Once you change 0 to 1 in alphaData the translucent parts of the png receive
> mouseClicks etc. You must be aware of that.
>
> Kind regards
> Bernd
>
>
>
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Convert-transparent-PNG-on-import-tp4688381p4688394.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

pmbrig
On Feb 3, 2015, at 12:28 PM, Marty Knapp wrote:

> Thank Bernd, I'll give that a try. Detecting mouseClicks or other mouse related functions aren't an issue for me in this case - it's that printing images with transparency on Windows can really come out strange and in some cases cause printing to fail.

if the platform = "Win32" then
   hide grc "transparentMask"
end if
-- print routines here
show grc "transparentMask"

This would take care of it, no?

-- Peter

Peter M. Brigham
[hidden email]
http://home.comcast.net/~pmbrig


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

Marty Knapp-2
Thanks Peter. It may be that we're mixing up two different threads here
- there's another about detecting mouse events inside images. In my app,
users create documents and are able to import images as part of their
design. These documents are then printed and a print job could include
hundred of pages. So I don't want to hide anything that the user would
expect to have printed.

On Mac I'm not having any trouble. On Windows, if the image has
transparency either by virtue of its format (ie. a transparent PNG) or
transparency has been applied by changing its blendLevel (to fade the
image), then very weird things happen. The image gets cut off, "borders"
or lines that aren't there get printed and on a long print run the app
will become unresponsive for some time and it may just stop printing.

I've filed 2 bug reports on this: 14089 and 14256 and they have both
been confirmed. If anyone is so inclined and are working on a Windows
machine, they could download the sample stacks and see what's happening.
My app is built with LC 6.6.5 but the issue seems to span the entire 6.X
series. On LC 6.7 the bug manifests itself a little differently but it's
still not working correctly.

As I didn't want to delay the release of my program, not knowing if/when
this would get fixed, I crippled the Windows version by disallowing the
import of PNG images as they might have transparency. I also disabled
the "fade" control. Not a very satisfactory solution. My thought here
was that if I could allow a non-transparent PNG to import but disallow
or convert a transparent PNG to non-transparent. That would be a little
better.

Instructing the user to not use a transparent PNG is not an answer. I
know someone will do it and then they'll be very unhappy with the results.

Marty K

> On Feb 3, 2015, at 12:28 PM, Marty Knapp wrote:
>
>> Thank Bernd, I'll give that a try. Detecting mouseClicks or other mouse related functions aren't an issue for me in this case - it's that printing images with transparency on Windows can really come out strange and in some cases cause printing to fail.
> if the platform = "Win32" then
>     hide grc "transparentMask"
> end if
> -- print routines here
> show grc "transparentMask"
>
> This would take care of it, no?
>
> -- Peter
>
> Peter M. Brigham
> [hidden email]
> http://home.comcast.net/~pmbrig
>
>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Convert transparent PNG on import?

pmbrig
My misunderstanding…

-- Peter

Peter M. Brigham
[hidden email]
http://home.comcast.net/~pmbrig

On Feb 3, 2015, at 2:39 PM, Marty Knapp wrote:

> Thanks Peter. It may be that we're mixing up two different threads here - there's another about detecting mouse events inside images. In my app, users create documents and are able to import images as part of their design. These documents are then printed and a print job could include hundred of pages. So I don't want to hide anything that the user would expect to have printed.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode