How do I make the background of a sprite transparent on Android? - android

I'm developing a game for Android. For the purpose of this question let's assume that I have a sprite of a red ball moving in space over some background or whatever.
I have a PNG file which I use to draw my background and a PNG file which I use to draw my ball over the background. The problem is my ball is a red circle on a 20 X 20 pixels PNG, meaning I have some white 'left over', so when I draw it on the screen, the 'white left over' appears over my background when I only want the red circle to.
I'm sorry but I'm totally new to animation. How do I crop my circle out of my square PNG or otherwise make the background in my ball PNG transparent? Do I do it programmatically or is there a way to paint my PNG so the non-relevant part is transparent?

Programs like Photoshop and GIMP allow you to set the background as transparent instead of white. Try editing your PNG in one of these and removing the white.

I suggest you use Paint.NET. You can use the magic wand to select the area you want to make transparent and then press "cut" (the scissor symbol) or press Ctrl + X.

Related

canvas drawing issue where paint needs to be restricted by black sketch

I need to create the painting application for the kids where kid can colour inside the black bordered sketch of any image
But, I am struck with the problem,that colouring can come outside the black bordering of the image...which i don't want to.Please guys help me to find out how to restrict the colouring by user within the black border of sketch
Also, I want that no colour should cover the black border.it should be inside the border.
I can post my code if required.
Look at Canvas clipPath and use the clipping built in to android to limit the 'coloring' of the kid/user to the regions you specify. You can then draw your objects as layers, kid/user colored layer on bottom, your sketch on top.
Finally..i have implemented it using mask bitmap and right usage of Portet.Duff mode

How draw a black ball in android?

I drew some colorful balls using OvalShape and RadialGradient. Here are the result:
All balls are good, except that the black ones look like flat. How to draw a shining black ball in Android? Thanks in advance.
The other ones look really good.
For the black balls, use dark grey instead of black. With the gradient in place it will look correct.

How is target area for SRC_IN xfermode drawing operation determined?

I'm writing an Android app that involves some 2D drawing operations. I am trying to use saveLayer and xfermode SRC_IN to draw the intersection of 2 images. It seems to work OK if I don't rotate anything, but if I rotate one of the images, it seems to treat the pixels outside the rotated rectangle bounding the image as opaque (part of the intersection), or more likely, as not part of the drawing operation (unaffected by the transparent pixels laid on top of it).
Below is a picture of what I'm talking about. The "5" and "3" images near the bottom are being "intersected" by drawing the "3" image (rotated) with xfermode SRC_IN on the "5". I have shown all three images on a gradient background to help visualize transparency.
After some thought, I suspect that the area outside the clipping rectangle of the "3" is not being treated as opaque, but rather simply not being treated as part of the drawing operation. What's interesting is that if I mark the layer as a software layer instead of a hardware layer the while number "5" shows up in the background instead of just the parts outside 3's clipping rectangle. I don't understand this.
How is the area affected by an SRC_IN drawing operation determined? (Normally it doesn't matter, but one unique feature of SRC_IN is that it has to turn opaque pixels transparent based on what is transparent in the image being drawn, so the overall size of that is drawn is important even though it normally wouldn't be.) How can I make the pixels outside the drawn area of the 3 be treated as not part of the intersection? Do I need to enlarge the clipping rectangle that is active when drawing the 3?

Draw canvas with avoidxfermode

This is my first post.
I'm developing a drawing application for Android and are opposite to a problem that I can not fix.
I have an image with various geometric shapes also superimposed. Each has a different colored geometric shapes.
With Avoidxfermode I can draw on the form with a specific color.
Now I would like the colorful picture is not visible to the user.
In practice I would recognize the area in which color through the colored picture, but I would like the new color to appear on a white image

Drawing bitmaps with empty areas

I need to draw a bitmap on top of a completely rendered GLSurfaceView. By completely rendered I mean that the entire thing is filled with colorized triangles. Obviously the bitmap will hide the triangles underneath it, but I would like to minimize how much is hidden.
The bitmap is 64x64 pixels and has many empty areas that are translucent in the PNG file. When I draw the bitmap by making a square with two triangles, the translucent areas become black (the green areas in the picture above), perhaps because the app background is black. Is there an easy way to get the translucent areas to not affect the image (the second image above)? Do I need to create a complex set of triangles that exactly outlines the non-translucent parts when I render the bitmap?
I am developing on a Motorola Xoom, Android 3.0. Thanks for your time.
Use the alpha test.

Categories

Resources