Background in black and image in white colour - java

im doing the project convert the image colour to black and white. what i want is to change the background that it will be black and the image will be white in colour..but mostly of the code that found is changing the image in black and background in white. can anyone know how to change? i already have a code for converting that image to Black and white.

Google is your best friend... http://android-er.blogspot.it/2015/02/invert-bitmap-using-colormatrix.html.
In this example you see that white becomes black and vice/versa.
It also works on all other colors as well.
And it's very fast, because it uses a ColorMatrix, not a pixel by pixel color change, which will wuold require width*hight operations.
It's a single pass!
[EDIT]
I thought you already had the black and white image.
If this is not your case, just use a greyscale ColorMatrix as reported in Lalit Poptani's answer here.
[EDIT 2]
To change brightness and contrast after desaturating (converting to greyscale), try the code found here: Here something to help changing brightness and contrast: http://android.okhelp.cz/bitmap-set-contrast-and-brightness-android/

Related

Program adjust transparent image for greenscreen

as a fun little project, I am trying to create an 'overlay' program.
Perhaps you've heard of the program 'open broadcaster software'.
This is a streaming program that can 'record' windows and apply 'color key' to them (making a certain color transparent)
I have a program that creates a window with a green background, acting as the greenscreen. On this window I want to make images appear, dissapear and move.
So far so good, however the problem comes with transparent images. They have a color hue over them because the color key tries to remove or smoothen out the colors.
So my question is; is there a way to programmatically add a color to a picture, or strengthen other colors, so color key would instead render the original?
Sincerely,
JB
Rendering a pertially translucent image on a backgroud showing the background color shining trough is the whole point of translucency.
There is nothing you can do without sacrificing the transparency in some way or another. A few useful effects can be achieved with java.awt.AlphaComposite, but I'm not sure any of the effects suit your fancy.
You could preprocess the images and change translucency to simple transparent/opaque (e.g. alter alpha for each pixel to newAlpha = oldAlpha < threshHold ? 0x00 : 0xFF). Selecting a good-looking threshhold value might be tricky (no one-size fits all). Needless to say that this will result in a drop in perceived image quality.

How to change color in lwjgl texture

I have the following texture:
The black pixels are characters, the background is transparent.
How do I change the black pixels of the characters to another color?
I use this texture as a bitmap for tekst rendering in lwjgl. Is there a way to change the black pixels to red?
I would appreciate an example.
As far as I am aware glColor* also applies for textures. If you change the black color of your font to white the given color would simply apply to this.

Getting alpha channel/opacity working for lighting

I have two pixel arrays, foreground and lighting. When I draw a white radial gradient (blurry circle) onto the lighting array, I want it to make the foreground visible - much like a torch in terraria/starbound. However, I also want to be able to mix different colors of lighting, rather than be stuck with black to white.
So how do I manipulate the pixel arrays so that they 'multiply' (I believe it's called)? Or is there an easier way using RGBA which I have not been able to get to work (flickering black on white or image getting ever more posterized)?
So far most responses regarding alpha channels / opacity have been using libraries from java which for this project I want to refrain from using.
Any help much appreciated!
If you want to know how the blending modes (such as "multiply") work in image editing programs on the pixel-value level, read this: How does photoshop blend two images together?.
Note that if you want to make the image lighter, you need a mode like "screen", because "multiply" makes it darker.

Canvas vs Image Android

I have a background image that is white and semi-transparent. This is used as a text container so you can differentiate between the background image and text.
Currently I am using an image that is a white rectangle with rounded corners, but of course when using this on different screen sizes the image is distorted, not massively or that noticeably, but would it be better or possible to draw this image with a canvas?
If it is possible would it slow down the app considerably?
UPDATE:
Thank you #jkhouw1 I have looked into 9 patch images and this seems very suitable. I am still interested in knowing the benefit of canvas against images, but if you post something as an answer I will accept it. Thank you.
use a nine patch is a graphic that android can scale appropriately. see here: http://developer.android.com/guide/developing/tools/draw9patch.html
and here http://www.higherpass.com/Android/Tutorials/Android-9-Patch-Scaled-Png-Image-Guide/
Haven't tried this yet, but I think this should be possible by defining a shape drawable. You can define round corners and you can make it semi-transparent by defining the color with alpha-value, for example #80FF0000 should be semi-transparent red.
I assume this would be a good solution both in terms of compatibility and performance.

Draw background for each cell in ObjectListField

I am creating a blackberry apllication which pre-dominantly uses ObjectListFields..All i need now is to draw an image as a background for each cell. I know this is quiet possible but i am not getting hold of the procedure. if i draw bitmap in drawlistrow() function the bluehighlight gets into the background and the cell highlight becomes very hard to read......can anybody help me with a code snippet to get through this problem ....thanks...
As far as i know ObjectListFields focus fills the background of the element blue and alters the foreground color (text) to white.
If you really need to draw an image on the background, you should at least change the foreground color to a high contrast or at make the background image transparent.
Check the style of the graphics in drawListRow with
graphics.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)and set different colors for them.

Categories

Resources