NSColor transparency on black background? - cocoa

In the background of my view, I draw a light blue color. And in the middle, i have a square box that is supposed to have an even lighter gray in it that has a 20% transparency. But for some reason the transparency is on top of a black background instead of a blue. I'm sorry If i'm not being clear.

You're probably using the wrong compositing mode to draw the smaller box. Show us your code.

Related

How to change the background color to white in WebGL with textures

Learning my way around WebGL but can't figure out how to change a simply background from black to white in this. It appears that this
gl.clearColor(255.0, 255.0, 255.0, 1.0);
does indeed change the background color to white, BUT as soon as the animation loads it updates the background back to black.
I'm stumped here. How do you change the background color to white and keep it from changing back to black?
The simplest way i can share what i'm doing is this example on codepen. if you can tell me how (and hopefully why) to change the background color on this codepen then you would help me significantly.
https://codepen.io/laxminegi/pen/xxYBOMj

How to avoid gray border after scaling an image with transparent pixels

When I use waifu2x model to scale an image with transparent pixels, the transparent black background seems to bleed into the image. Using bicubic interpolation also has this problem.
As specified in this blog, the transparent background can be filled with color as near as context as possible.
It's simple to find borders of such transparent borders. But is there any algorithm to generate such background?

Detecting anti-aliased or undersampled text image

I have an image that is essentially a text document (black and white) but due to anti-aliasing/undersampling applied during scanning, the image contains a lot of color, light tone pixels and is thus saved as a full-color image i.e: takes a lot of space.
My goal is to be able to detect Black and White image candidates in order to convert them from full color to B&W which dramatically reduces their size.
Is there a way to detect such anti-aliased/undersampled images? Doing color pixel analysis doesn't help because the colored pixels end up being close in amount to the black pixels... Essentially I want to be able to detect that the colored pixels come from anti-aliasing/undersampling a black & white image and not from a picture type image.
Here is an example image:
As you can see there are many more colors than just black. However this image is a good candidate for Black & White / Greyscale conversion instead of full color. How can I detect such images? Please note that in this example the colors tend to be on the grey side but there are many cases where they are cyan or brown etc.
I think it is a valid question. I don't have 50 reputation to post a comment so I will post this as an answer.
Basically, in a black and white anti-aliased image the various grey colors are opacity differences of the black color. If we observe those pixels they will be like these listed below. So, if the operation is a color manipulation then apply the same opacity picked up from those grey pixels to the new color.
rgba(0,0,0,0.6)
rgba(0,0,0,0.9)
rgba(0,0,0,0.5)
rgba(0,0,0,0.9)
rgba(0,0,0,0.6)
rgba(0,0,0,0.1)
rgba(0,0,0,0.5)
In my opinion, the pixels other than grey, in this example image, cyan and brown as it appears can be safely ignored because they seemed like not part of the original text. If there were a few more example images of non grey pixels would have been good. But if we cannot ignore them just need to get the pixel opacity and apply the same color manipulation. In other words we treat them as black pixels.

Setting the background to transparent using GIMP

Using GIMP 2, I have an image of a grey chair on a white background, as below:
I now want to set the background to transparent. Therefore, I decided to use GIMP's "Color To Alpha" tool. So, I told it to set all pixels which are white (255, 255, 255) to transparent, as below:
This did set all white pixels to transparent. However, it also set the grey pixels on the chair to be partially transparent, as below:
So when I export this image and place it in front of a background, there is no white box around the chair -- but the background partially shows through the chair.
What am I doing wrong?
First, this question is offtopic here, and should be on https://graphicdesign.stackexchange.com .
Second, it is trivial enough just to answer: the color to alpha plug-in is not there to turn a single color, as seem on the image, to transparency: it is a sophisticated plug-in that will remove one color of your image in a way that, if you lace the new image over a background of the same color the color you removed, you get the original image back.
Thus, in your case, it removed the "whiteness" of your chair, transforming all pixels to different opaque shades of black - so that when placed over white, you get the original image.
To simply remove the white, you have to cick on the Select By Color tool (by default th 5th icon on the toolbox), click on the white background to have it selected, and then just edit->cut. (It won't work if your image layer does not have transparency to start with - if that is the case, prior to edit->cut do Layer->Transparency->Add Alpha Channel).
If you get aliased borders, then, after edit>cut, but prior to dismissing your selection, you can do Select->Border... by 1 or 2px, and then use the color to alpha filter with White on this selection.
For more information on Color to Alpha, I have this other answer its use and comparison with edit-cut here: https://graphicdesign.stackexchange.com/questions/28058/gimp-color-to-alpha-is-not-selectable/28097#28097
Just use a selection to restrict the action of Color to alpha where it matters: backgroundand edge pixels:
Select background with fuzzy select
Select>Grow by one pixel so that the selection ofverlaps the edge pixels
Color>Color to alpha

CIFilter HueAdjust

How to programmatically change the hue of UIImage?
I am using the above page's advice, for Core image filter CIFilter. The only problem I am having is my when I rotate to a yellow hue, it's a dark mustard yellow, and I can't get the brightest vibrant yellow, ie R:255 G:255 B:0. I have images that are on layers that are made up of a simple color R:255 G:0 B:0 I just want to rotate around, to get the basic colors plus orange. Orange works fine tho.
I just don't know why when I rotate from R:255 to try and get R:255 G:255 Yellow it's a dark yellow.
I am using 1.04719755 for the Yellow float, at deltaHueRadians
I don't know it's just weird this is the 3rd attempt at this but I keep getting a dingy yellow.
I realized the problem.
In Photoshop I have done so many Colorize operations when I used to photo edit, I got them confused with Hue Rotation.
Basically when you Colorize in Photoshop, it will "Colorize" the image not just Hue Rotate the values.
The difference between the two is a very thin line depending on what images you use. I don't really feel like going into a complete explanation but...
Say you have a grey cube on a layer, and you COLORIZE the image, the cube will rotate colors as you use a slider. If you Hue rotate it will stay grey.
But if you take a red cube, and hue rotate, then the hue rotation will take you thru colors, not necessarily all of them tho like a colorize.
I believe the issue has to do with all that good ole HSV RGB matrix crazy math problems. Which I am not doing right now. Keeping it simple.
I decided to just do a colorize method with:
CGContextSetBlendMode(context, kCGBlendModeMultiply);
With grey objects and this is perfectly what I wanted.
from googling I found this:
http://coffeeshopped.com/2010/09/iphone-how-to-dynamically-color-a-uiimage

Resources