I am new to xamarin forms. I am trying to display an image with "Transparent background" (Grey and white) but this is how it show on the application.
I am using PNG file for the picture as I saw the other thread commenting on PNG/JPG files but it did not work.
I also try with opacity and backgroundcolor="Transparent" but it did not work either.
The image is random transparent background image got from google.
Any help is appreciated! Thanks.
Picture of the application
<StackLayout BackgroundColor="OrangeRed">
<Image Source="icon11.png" Aspect="AspectFit" />
</StackLayout>
As Shaw mentioned in the comment, I made a blunder on the transparent background PNG files.
I tested with a transparent background xamarin logo from pre-built xamarin form pages and it worked.
Conclusion for my case: Double check if the picture actually has transparent background.
Detail Info:
The picture I used and shown above does not actually have transparent background, one can check when open it from your PC (It will shows the white and grey boxes).
Not "Real" Transparent Picture
Actual Transparent Picture
Related
I have a plan svg converted into image.png
i'd like to detect the circles green and trigger a click event and show a tooltip/alert over it .
i posted last time a Plan Interactive SVG with Xamarin Forms but dealing with svg, and i think it is impossible , so i tried to work with png file ,
Plan.xaml
<ContentPage..>
<Image x:Name="_plan" Source="image.png"></Image>
</ContentPage>
else , if there is a simple way with svg.
I have an image with irregular shape. I set it as a background image of an UIButton.
Now, I use OBShapedButton library to enable touch only where image is non-transparent. But, for some reason if I click on transparent image area, when view appears in screen, then it responds to click, whereas it should not.
I made some area of image transparent using adobe cs4 photoshop. Now, I want to try making it transparent in xcode only. May be it helps.
To have an idea of image shape I am attaching a sample image.
Does anyone know how to do that?
Maybe I am missing something, but is it the case that when you set a pictureboxes background to transparent, all it really does is set it to the same color as the forms background?
What I am trying to do is draw an animation for the benefit of this, a bouncing ball - which I paint on the form, then overlay that with a picture frame. End result should be a bouncing ball in a picture frame, I should mention that the picture frame does not have a straight edge, so it is not possible to arrange 4 picture boxes in a frame. The ball needs to vanish behind the frame to change color and then magically bounce back out.
I have tried:
1.Setting the picture box background to pink and then key out the same pink, this basically cuts away everything, including that which is behind the picture box
2.Setting the picture box to transparent, this just displays the picture box background as the same color as the forms background.
3.I have tried painting the image in a rectangle, this had the same effect as drawing it in a picture box.
I am not sure what I am doing wrong, I am wondering if there is any other ways I could try or if someone has made a custom control or library that supports transparency?
Try using a Panel with the background image set. This is because; as you said: the transparent option only takes the backcolour of the parent.
After doing some more in depth research I solved this by drawing both the images to the form using PaintEventArgs and me.paint
Making each image transparent using:
Dim TestImage as Bitmap
TestImage.MakeTransparent(<Transparency Color>)
Thank you to both of you for your replies though.
Hmm... If You want to use Picturebox and get a transparent image,
Try to set picturebox's background as your 'Ball' (probably you need an image editor).
and set picturebox transparent. It worked for me (VS Express 2010) once.
Trying to start a game that involve in a lot of .png and animation.
All these .png are already transparent and set to an individual picture box when i overlay one over the other. There "transparency" actually gets the form background color. and not i'm not able to see through the image behind it.
i set the forecolor to transparent in the attribute am i missing something?
*side question... should i make my game in vb.net if it using a lot of images and animations files? (working solo might get my friend to help later)
Example pictures
well, this is a bit old, but check my answer here :
Make Picturebox transparent over other picturebox?
I've been working on some custom graphics controls, and I found this weird problem with windows 7 rendering my button controls. I've used Photoshop to delete the pixels in the background all around the button image I'm using, then saved it as a GIF, and imported it into VS to use as the background image of my button. When windows XP renders it, it is fine, but when windows 7 renders it, all 4 corners have an odd white border around them.
You can barely see them in this pic, but they are much more apparent when looking at them on the client PC's.
Is there something wrong with the way I am transfering the image? should I not use a gif? is there something wrong with the way I am displaying it on the button? What can I do about it?
GIF was a bad choice, it can only render images with 256 colors. You need all the colors you can get to make the anti-aliasing work properly. Use PNG.
You will also need to make sure that the background color of the container is the same as the one you used in Photoshop, the anti-aliasing pixels will otherwise have the wrong colors. And you cannot stretch the image, that will also stretch the anti-aliasing pixels, ruining the effect.