Arbitrary blending of semi-transparent PNG, retaining alpha on iOS - ios

I want to be able to overlay a semi-transparent PNG with a single colour using an arbitrary blending and keep the alpha.
I'm aware of this solution:
How to tint a transparent PNG image in iPhone?
Unfortunately, DestinationIn / SourceOut / Mask all display noticeable visual artefacts in the alpha regions. This is especially noticeable when layering graphics:
Aside from using Core Graphics, I've tried CoreImage, which does not display any artefacts in CIMultiplyCompositing, but has no corresponding filter for the other Core Graphics blend modes (such as Screen and Overlay)
I've also worked with GPUImage but encountered the same visual artefacts, although this appears to be a bug in the library.

I found and fixed the bug in GPUImage which was causing the problems. I then manually implemented all the blendings as shaders.

Related

p5.js problem with png alpha in webgl mode

I noticed a problem in p5.js when rendering png images with soft alpha in WEBGL mode.
I'm rendering 10 images that are supposed to be "halos", made in photoshop all white with a blurred point mask, exported as PNG24.
In canvas mode this works ok and images overlap as supposed.
However in WEBGL mode I get a dark halo around the images
any ideas?
I discovered it has to do with known issues of trasparency in WebGL, and the way P5.js manages it:
https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html
In my case I managed to make it work this way:
//renderer is a p5.js renderer
var gl = renderer.GL;
// Turn off rendering to alpha
gl.colorMask(true, true, true, false);
BUT I lost canvas transparency, that would be quite useful for this project.

XNA Strange blur on my transparency .png

(i can't post images so i posted links instead)
i'm working on a 2D platform game using pixelperfect.
The problem is about the png images used in-game. On transparency, there are some blur.
like this :
http://i.stack.imgur.com/lBX3A.jpg
If i open the texture with TheGimp, this is what i get :
http://i.stack.imgur.com/pOeF4.jpg
this is a sample of my map (zoom 1600x).
As you can see there is no blur around the black. (the grey squares means transparency).
Tests i did :
save without compression and re-opened it = no blur.
to be sure, i added a white background in gimp (it's easier to see the dark blur on white) :
(http://) i.stack.imgur.com/jfhWv.jpg
of course, i removed the white background because i wanted it transparency.
last information : there is blur on every transparency png images, even on my spritesheet character. When i animate it, i can see the blur from others frames.
After my tests, i concluded that gimp isn't the problem.
Can you help me ? Thx for reading.
xna4, c#2010 express edition, gimp2.611.
Sorry about my english ^^
This happens because of "texture filtering", which xna does by default.
You probaly can disable this.
found something: https://gamedev.stackexchange.com/questions/6820/how-do-i-disable-texture-filtering-for-sprite-scaling-in-xna-4-0

Convert PNG32s to PNG8s and with matted indexed transparency

We have a range of product images that have been clear cut by our graphic designers and have been saved as PNG32s with transparent backgrounds. We need to convert these to PNG8 as they are uploaded to the website (using ImageMagick) so the files are nice and small.
The images are displayed at various positions over a grey gradient background so they need to retain their transparency.
Because the PNG8s will have indexed transparency, we want to matte just the semi-transparent anti-aliased edge pixels with the average grey of the gradient.
What's the nicest way of doing this im ImageMagic? I've found lots of cool ways of transforming/removing/flattening the alpha channel but it doesn't help much with the task of targeting and matting only semi-transparent pixels. Anyone done this before?

How to apply a soft shaped shadow to graphics which have transparent areas in them?

Normally I'm using CALayer shadowRadius, but now I also need to use UIImage and apply shaped shadows to it based on the content in the image.
For example when I have a layer with text in it and I set a shadow, it works automatically on the text and not just on the rectangle of the layer.
In Photoshop this is known as "layer style" and it automatically works based on the shape of the image content.
I am afraid that I need to implement some Harvard-Stanford-MIT-NASA kind of hardcore logic to apply a shadow on a "shaped image", i.e. an image of an round icon where the areas around the icon are fully transparent.
I'm able to manipulate images on a per-pixel level as I'm doing this already to draw charts, so if there was an open-sourced implementation of some fantastic algorithms this would be fantastic. And if not: How does this basically work? My guess is I would "just" try to blur a grayscaled version of my image somehow and then overlay it with the non-blurred version.
My guess is I would "just" try to blur a grayscaled version of my image somehow and then overlay it with the non-blurred version.
That's pretty much it, actually. Except instead of blurring a greyscaled version of the image, blur a solid-colored version of the image (i.e. keep the alpha channel, but make all pixels black). Although CALayer's shadowing should do this already for you.
If your images are already composited onto a background (i.e. without real transparency), you have a harder problem as you first need to "remove" the background before you can have the shape of the object in order to generate the shadow.

How to get great looking transparent PNGs on BlackBerry?

I am able to use PNGs that have drop shadows but the effect when displayed on the BlackBerry looks like it collapses the transparent channel down from its original smooth gradient to only several transparent values giving it a choppy look.
The same issue is encountered by drawing on the UI using BlackBerry fields or the graphics.drawBitmap method. Anyone want to share hints for getting great looking transparent effects on the BlackBerry?
Dither your images or pre-composite them. When loading an image on a BlackBerry, you get at most 4 bits of alpha data, which allows 4 bits each for RGB. So, if you want to dither your transparent images, go for RGB4444. If you don't dither them, that's what causes 8-bit alpha to just be mapped to the nearest 4-bit value.
If you include no alpha data (i.e., precomposite), you can get RGB565, which will have a better image quality overall, but you will have to deal with static positioning for your dropshadows.

Resources