Circular images - vb.net

In my application, users are allowed to choose a picture they want and this picture shows up in a picturebox.
I want to know if there was a way so that this picture that they select becomes circular instead of a square?
I want all images they select to be circle shaped.
Is there anyway to do this? Doesn't even have to be a picturebox control, anything that can accomplish this is fine
I tried this with no luck - http://www.codeproject.com/Questions/430531/circle-shaped-picture-box

Not the smartest way, but worked for me in similar task. If your picturebox is fixed size, you can create "mask" which will hide the corners.
Just draw an image in PNG with transparent circle in the middle and make the rest same color as your form. Use this image as Image propperty of each imagebox and set your image as "backgroundImage" property. This way, the image will look circle-shaped.
If you need imageboxes of different size, you can create the circle mask programmatically.
EDIT: If you will prepare a calculation of circle, you can also use it to "crop" the images to circle shape. It all depends on what you want to do with these images later.
Do you need to use them later in circle or rectangle shape?

Related

Crop Image in specific shape Cocos2d

I have an UIImageView* shape which is in fixed position. Behind that view I have another view which I can move, scale and rotate with gestures. I would like when I finish with customising the view behind the "shape" to press a button crop and crop the image. You can see video here of what exactly I am trying to do.
Video: https://www.youtube.com/watch?v=4CTNGire1gQ&feature=youtu.be
You can mask one image with another image to get custom shape image. See tutorial to get some idea about masking
http://www.raywenderlich.com/4421/how-to-mask-a-sprite-with-cocos2d-1-0

How can I draw a banner or other adornment over an image using XAML in a Windows Store app?

Here's basically what I'm trying to accomplish:
I can get the image drawn and placed appropriately, but I'm at a loss for how to draw the banners. It's easy enough to put both elements in a Grid, but I can't figure out how to get the banner positioned/sized based on the aspect ration of the image that gets loaded.
If this was WPF I'm pretty sure I could just use an Adorner, but in WinRT I'm not sure how to proceed.
There is nothing kuje the Adorner in WinRT. Place the image and the banner into a grid, set the banner's vertipcal alignment to top, horizontal alignment to right.
If you want the banner to always be the same size, set Stretch to None. Otherwise hook into the Loaded event of the image where you can get the image dimensions and set the banner dimensions accordingly.

Picture Box and Form Transparency

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.

How to create letterpress effect?

I'm looking to implement something like the famous "letterpress" effect in my application. Here's what I'm talking about: (just a quick example made in PShop)
As you can see, it looks like it's pressed into the background. I wonder if it's possible to do something like this on the Mac dynamically. Is there a way? Thanks!
You can do the gradient fill portion of the text using the code I provide in this answer. Check the coordinate space first, because I described that for the iPhone, which has an inverted Y axis when compared to the Mac's normal Quartz coordinates.
The text is first used to create a clipping path, and the gradient is drawn within that path.
As far as the internal shadow, you might be able to draw this after the gradient is drawn by using CGContextSetShadowWithColor() with an appropriate downward offset and black color, then drawing the text again using just the stroke of the text. deanWombourne has some sample code for a similar task in his answer here.
Draw the text with a normal font to create a black and white bitmap of the text.
Draw another image that is is the same size and completely filled with the gray-to-white gradient you have above.
Create a completely white image with the same size as your other images.
Draw your back and white text image (1) onto the white image (3) with NSCompositeDestinationOut.
This gives you a white image with your text cut out.
Draw the white image with the text cut out on top of the gradient image and apply a shadow while drawing.

Assigning a Background image to CGRect Object!

I am new to iphone Programming . I have a rectangle on which i display some data. I want to assign an image to its background. And is it possible that the data would be visible even after the image is assigned . Any idea how i can do it ?
Thanks
You don't say how you are displaying your data, so it isn't possible to respond properly.
But in general, you create simple displays using Interface Builder, and can position a UILabel over a UIImageView, and can set the labels background to be transparent.
If you are drawing using drawRect:, then you probably shouldn't be. And yes, you can draw text over an image doing it this way, too.
CGRect is just a structure representing an abstract rectangle. You do not associate styling information (e.g. color, background image, etc.) to it because this does not make sense.
If you simply want to display an image on a window, drag the PNG image into your project, then you can find your image in Interface Builder, which can be put onto the window.