Best way to display rounded corner image with sprite - directx

I need to display image with rounded corner with sprite. What is the best way to do this.

I explained how to do it in your other post ...
How to clip the texture in rounded shape

If you mean of smoothing the corners of the image you're drawing, there is no way to do with the normal sprite interface (other than modifying the original image to be smoothed beforehand)
To do it you must work with shaders.

Related

What does normalizedPath refer to and how can I draw it over an image in iOS?

I have two images, one that is a monochrome one which is a mask and another one with full color. What I need to do is find the CGRect of the mask (white pixels) in the other full color one.
What I did is to first find the contour of the mask using the Vision framework. Now, this returns a CGPath which is normalised. How can I translate this path into coordinates to the other image? Both have been scaled the same way to make them the same size so the translation should be "easy" but I can't figure it out.

android: smooth out edges of random shape bitmap

I have an random shape bitmap cut out by user. I want to fade out its borders i.e. contours, so as to make it appear smooth. What should I do? To get the borders and color of every pixel in bitmap, I am traversing it pixel by pixel. It takes long time, still I am ok with it. Is openCV my only option? If yes, can anybody point me towards any tutorial or suggestion for logical approach?
You can just run a smoothing filter on your shape.
In opencv you can use the blur fnnction or gaussainBlur. Look at http://docs.opencv.org/2.4/doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html.
You don't have to use opencv but i think it would be easier and faster.
If you still don't want can use any other code that implement smoothing an image.
In case you just want to effect the border pixels do the following:
Make a copy of the original image
Filter the entire image.
Extract the border pixel using opencv findContours.
Copy from the blurred image only the pixels in the border and in there neighborhood and copy them to the copy you did in step 1.

Is it possible to transform a UIView in a circle image?

I have downloaded the new Facebook messanger App for iOS. I was wondering, is there some option that allows to "crop" an image and leave only a circle?
Would be great to be able to put a UIImage which is rectangular and crop the circular part.
Or do you think this is done server-side? In other words, there is no special iOS cropping function but simply a cropping software on the Facebook server?
use
imageView.layer.cornerRadius=imageView.frame.size.width/2.0;
imageView.clipsToBounds=YES;
This is actually quite easy to do.
What you want to do is to create a CAShapeLayer the same size as your view. Create a UIBezierPath that uses a rounded rectangle who's corner radius is 1/2 the height/width. That gives you a circular path.
Install the bezier path's CGPath into the shape layer. Then set the shape layer to fill with an opaque color.
Finally, install the shape layer as the mask on your view's layer. The result is that the shape layer clips the view and only shows the opaque parts of the shape layer.

why resizableImageWithCapInsets's best performance is tiled by 1x1 rather than block by block

UIImage resizableImageWithCapInsets official document description are below.
During scaling or resizing of the image, areas covered by a cap are not scaled or resized. Instead, the pixel area not covered by the cap in each direction is tiled, left-to-right and top-to-bottom, to resize the image. This technique is often used to create variable-width buttons, which retain the same rounded corners but whose center region grows or shrinks as needed. For best performance, use a tiled area that is a 1x1 pixel area in size.
I don't understand why use 1x1 pixel tiled area is the best performance. I think tiled block by block, the performance is better than 1x1 area. In theory, block by block is fast than point by point, is that right? who can told me the implementation of this in machine?
#jhabbott makes a good guess in his comment on the accepted answer to the question How does UIEdgeInsetsMake work?
So, I think if the tiled area is just 1x1 pixel. Then, resizableImageWithCapInsets: can just use that pixel's color as the fill color. That way, it doesn't have to do any tiling at all. So, essentially, it's like setting view.backgroundColor = color. Have you ever written any drawing code? Basically, I think filling an area with a color is easier than tiling that area with a rectangle of pixels, since the latter probably takes more calculations, like where to position the next tile, etc. But, I'm just guessing here. But, if you try to write the drawing code to fill a rect with a color vs to tile a rect of pixels onto another rect, you'll see where I'm coming from.

XNA Texture Stretch Fuzzy

If I stretch a texture to a destination rectangle, and I have a simple 1X2 sprite (windows forms button background) XNA stretches the sprite very fuzzy, I get a gradient instead of the bottom part dark and the top one light.
Is there something like a stretchmode so I get the texture stretched as I created it in Photoshop?
Thanks
As per this question:
GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;

Resources