XNA How To Make Transparent Texture - xna

I read and try that pure Magenta Color 255, 0, 255 in an image is automatically transparent, but unfortunately failed, is there anything should I setup first?
Also I read and try include alpha in a PNG Image, the strange is when I used it on a project it's work, but not on the other, what is likely wrong with the code?
Please kindly reply, thank you

For Magenta to be transparent, look at the properties of your image file. Right click in solution explorer, properties.
There is an option there to specify the transparent color to be used (magenta by default).
Then, there is the rendering to consider. How are you drawing your texture? With SpriteBatch, it is automatic, but you may have sorting issues. Check the order in which you draw your textures and the SpriteSortMode.

Related

Adding border to edges of opaque area of UIImage with a filter

Hello: Currently in my project, I'm using OBShapedButton to process touches on a lot of objects that overlap (it's a map with each territory its own separate object). Basically, this library prevents a touch from being processed on a transparent point on the given view.
I'm attempting to add a border effect to just the edges of the opaque part of the UIImage (and adding a semi-transparent overlay above that). Something to the effect of this:
Which can be simplified to this (example of one image):
I am currently using MGImageUtilities to color in the opaque parts of territories using this line:
[territory setImage:[[territory image] imageTintedWithColor:tint]];
The problem is that I'm not sure how to just color the borders (which can be any shape). I've looked at this link already, but haven't been able to come up with anything.
Thanks in advance for the help!
Terribly hacky, but use MGImageUtilities' UIImage+ProportionalFill with scale resizing to create a slightly larger image, UIImage+Tint to red, and stack below.
The library you are using doesn't actually specify a shape layer. It uses alpha values from the PNGs that you give it.
Could you use a different 'highlighted' or 'selected' PNG that adds the border effect you are looking for?
Otherwise, it you will have to generate a UIBezierPath from your PNG image, which sounds like a very computationally intensive operation. At that point, I might question whether this library meets your needs.

Render water-paint in iOS

I have been working with OpenGL in iOS, and setting the colors with glColor4f(r,g,b,a) and then drawing my own color on a white UIImageView. I basically have a brush, which is then moved around my user's touch, and then it paints the color onto the canvas. But this color needs to be water paint (like smudged color)
Does anyone understand/knows how to get a water color like this app does, and how the background UIImageView has a texture on it?
https://itunes.apple.com/us/app/hello-watercolor/id539414526?mt=8
or checkout water paint in this. http://www.fiftythree.com/paper
I created a bounty on this as I am really having a hard time to grasp how to derive such smooth flowing colors out of the normal colors. Even if you guys point me in the right direction, or to some sample code on how I can get the effect of water-paint, it would be really helpful ^_^
And as a bonus, it would be also be helpful if you can point out to me how to get canvas on which it is painted on looks realistic, and blended with the paint? Does Blending/GLSL have to do with any of this?
Is there any sample project on this?
If you are still struggling with the basics of getting realistic looking water colors working, you may want to experiment/prototype in photoshop first.
http://www.zoepiel.com/tutorials/watercolor/ shows some very effective tricks for creating watercolor images with simple tools.
The most interesting one is to multiply a group of watercolor layers with a greyscale watercolor paper image. The texture of the paper makes some parts remain white, and other parts saturate with color, just like real watercolor.
Each layer remains 'wet' in the sense that the colors within it blend, but the layers are 'dry' with respect to each other.
She also explains some of her brush and blur settings and shows what they do.
Once you can produce the desired effect in photoshop, you'll have clear specifications of what you want to do and you'll be quite a bit closer to programming it out.
Looking at the examples you posted, it looks like they are using a simple Gaussian Blur with a radius of double your brush size. This may be an incomplete solution, but it's at least the first level.

Multiple Transparency Layers

Please be kind, I'm new to this....
I have an application that I'm developing where I need to take a PNG image, which has a transparency layer, and treat another color (I'm thinking of using RGB( 1, 1, 1 ), since it's so close to pure black that I can hard-code it) as a separate transparency layer. The reason for this is that I have a background image sitting behind the PNG image that I would like to still display as my sprite gets filled (by adding a progress bar to the sprite), and I only want the portions of the sprite that aren't of the given color to reflect the color fill of the progress bar. In this way, I can avoid having to deal with vector computations for the outline of the image within the sprite, flood the area outside of the discernable image with my new "transparent" color, and be on my merry way.
I've tried using shaders, but they seem to be less than helpful.
There is no way that I know of due to Open GL not allowing you to do it. You will either have to modify the pixel data manually or write a shader (Which you hav already done ).

how to fill solid color into the shape of a transparent PNG file with actionscript3?

For example, I have a transparent png file, the shape is a car.
In the png file, I only draw the white border shape.
Outside and inside the border are all transparent.
I want to use actionscript3 code to show the car object with different color, it means only fill color inside the border, and for the outside of the border, keep transparent.
How to do that?
So far, the simplest workaround is to prepare many images with PhotoShop, but it's not good enough for me. When I have many shapes and use many colors, I've to prepare many many images.
Add more details:
(Because I'm using white border, you may not see the basic png file if your background of browser is white)
Change my boarder of shape to black, hope this is helpful to understand my question.
Since you're working with loaded images/pixels you can make use of BitmapData's floodFill() which pretty much does what you need. There's an example in bellow the method description as well.
It does pretty much what you need, although in some cases it might not be perfect. It's worth having a look at Jan's optimizing the floodFill() method article which goes more in depth.
A simple solution is to use multiple layers. The top layer would contain just the border. The lower layer would contain just the car with no border. You can adjust the colour of the car layer using a ColorTransform or ColorMatrixFilter.

How to put a transparent color on a form?

I have a form with an image as the background.
Now I need to put several transparent dark color areas in several areas off the form.
I need not to hide the background. How can I do this?
Standard Delphi control do AFAIK not support that kind of transparency. You therefore have two possiblities:
use third-party components
create your own component (you can derive from an existing one) and override the paint method. In the paint method just draw the correct part of the background image and darken every pixel to get the effect you want.
You can try Delphi 2009/2010 which supports using PNG images. The PNG image format allows for alpha layer transparency, which it sounds it what your looking for. This assumes that your wanting a fixed shape on your form.
EDIT-- For Delphi 2007, you can attempt to use the PNG Components which if I remember correctly do properly handle alpha transparency.
Is the background image and the darker areas the only thing that you want on your form, or do you have other components that should be blended too?
If it's only the background image and the dark areas, I would recommend that you check out Graphics32. It's an image control supporting layers. It should be fairly easy to archive what you want (or what I assume that you want...) from that.

Resources