Color is getting darker when using alpha channel / opacity - colors

I draw to a texture with a fragment shader in opengl.
I set my color to 100% red and 50% opacity, but when i then read this color i discover that it is no longer 100% red.
The same can be noticed with gimp.
I choose 100% red color but draw it with 50% opacity, when i then use the color picker tool, it tells me the red color is only 80%.
Is there a way to preserve the color value in opengl es 2.0?

The color is modified by the Bending function and operation. You have to disable blending.
There is no opacity, there is just an alpha channel. The alpha channel and the blend function define how a source color is mixed (blended) with the color in the target buffer. Hence if blending is enabled, then the final color is equal to the source color. If blending is disabled, the the color and the alpha channel are copied to the target without manipulation.

Related

Without alpha path how to decrease edge effect while paste icon

I got a RGB332 LCD and a poor MCU to drive it . The MCU do not have a hardware accelerator nor do RGB332 display support an alpha path.
So I used the color "black" as a "alpha color" to deal with icon paste work.Which means I fill the icon color data to background buffer while the data is not black.
The problem I meet is that the icon showed it's own antialiased edge while the background is not black. And the "antialiased edge" just makes an edge effect from the background.
Is there any way to deal with the situation ?
The main problem is that I don't have "Layer" and "Alpha" to do the PS-like merge work.
But the Icons are Pasted to a Frame buffer one by one.
So my solution is :
When each icon is being pasted,I could decide the front/background,
which means I could detect the "antialiased edge" of the icons just
like I have "layers".
After I find the antialiased edges ,I filled the pixels with the
middle color of the front/background.
The LCD is RGB332,and the middle color calculation is just filling
the edge with 75% background color + 25% front color. If the icon
color is carefully designed, you don't even need a float calculation
.
The work maybe not that effective ,but really solved my problem.

LibGDX - change the inside color, not border

I have a rounded square texture, drawn in paint, with black border. How can I change only the inner color without changing the border color?
EDIT: I did it, but I want to ask if it can be done without using another texture? I also wonder if there is a connection between this and 9patch as in scaling. Can we use that or is there something like that?
You can tint whatever it is what you are drawing, using SpriteBatch. This means that color you specify is multiplied with the color of the image. For example if your image is a white rounded rectangle with a black border and you tint it using the color purple then the inside will be purple and the border will remain black. You didn't provide enough information to be more specific. But if you are for example using the Sprite class then you can use the setColor method to tint it. Likewise if you are using the Image class. If you are drawing the "texture" directly using SpriteBatch then you can use the setColor method of the SpriteBatch.

GIMP - Alpha to Color

I have created a simple square using GIMP which color is a shade of blue (#07192c). I lowered the opacity on this square a bit, and realized I like the shade of blue which was now created from lowering the opacity.
My question is, does GIMP have a function which allows you to select (like the eyedropper) the color of a transparent layer? I've searched but can only find 'color to alpha' which is not what I'm looking for.
You can activate the Sample merged option of the Color Picker tool. This will pick the color as it is shown in the image composition.
This setting is available in the tool options for the color picker:
Layer -> Transparency -> Remove Alpha Channel
Colours -> Map -> Colour Exchange...

color blending with GDI+

I am refering to a older question saying color blending with GDI+
Using GDI+ with Windows Forms, I want to be able to draw with a pen and blend color based on the destination pixel color.
For example, if I draw a line and it passes over black pixels, I want it to be a lighter color (like white for example) so that it's visible. When that same line passes over white pixels, it should be a darker color (black for example) so that it's still clearly visible.
the answers says to use a color matrix for transformation
so i started implementing it..
My image is present in raw data format in rgb48
Gdiplus::Bitmap image(input.width,input.height,input.width*6,PixelFormat48bppRGB,(unsigned char*)rgb48);
Gdiplus::Image *images= image.GetThumbnailImage(input.width,input.height);
Gdiplus::TextureBrush brush(images);
Gdiplus::Pen pen(&brush);
Gdiplus::ColorMatrix matrix={
-1.0f,0.0f,0.0f,0.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,0.0f,
0.0f,0.0f,-1.0f,0.0f,0.0f,
0.0f,0.0f,0.0f,1.0f,0.0f,
1.0f,1.0f,1.0f,0.0f,1.0f,
};
Gdiplus::Graphics gfx(&image1);
Gdiplus::ImageAttributes imageAttr;
imageAttr.SetColorMatrix(&matrix);
gfx.DrawImage(images,Gdiplus::Rect(0,0,input.width,input.height),0,0,1024,1024,Gdiplus::UnitPixel,&imageAttr);
I am not getting what i expect..Can some one help me in finding the mistake i m doing.
You can use the alpha component of a color to specify transparency, so that colors can be combined. However, if you want the combination to be something other than the alpha blend, you must draw the pixels yourself. You could first draw into a transparent bitmap, then render that onto the destination pixel by pixel.

What color blending algorithm does MyPaint use?

I am confused with how does MyPaint blend color, here are what I did:
It has a background layer (initial white color).
Select a brush with some color and alpha < 1, paint some lines on the canvas.
When I paint at the same line, it will be deepen.
Change the background layer to any color or image, the line still look nice.
So, my questions are:
How does it blend color when I paint at the same place with alpha < 1?
How does it blend color between canvas and background layer?
Thanks.

Resources