Trying to draw scaled UIImage in custom view, but nothing's rendering?

I commended out the calls to GraphicsBegin and GraphicsEnd and the image renders - but many things that I read indicated that one should create a graphics context in this way If those were the names, then it would make sense that you would need to call them before and after drawing But those are not the names. The full names of the functions, as you used them in your code, are: UIGraphicsBegin Image Context UIGraphicsEnd Image Context These names hint that these functions are for a specific kind of drawing, and the documentation backs that up: You use this function to configure the drawing environment for rendering into a bitmap. €¦ While the context created by this function is the current context, you can call the UIGraphicsGetImageFromCurrentImageContext function to retrieve an image object based on the current contents of the context That is what these functions are for: Making a new image by capturing some drawing Your situation is different: You already have an image, and you are a view that has been called upon to draw.

This means that you already have a current context and you need only to draw into it So, don't create a context—just draw.

I commended out the calls to GraphicsBegin and GraphicsEnd and the image renders - but many things that I read indicated that one should create a graphics context in this way. If those were the names, then it would make sense that you would need to call them before and after drawing. But those are not the names.

The full names of the functions, as you used them in your code, are: UIGraphicsBeginImageContext UIGraphicsEndImageContext These names hint that these functions are for a specific kind of drawing, and the documentation backs that up: You use this function to configure the drawing environment for rendering into a bitmap. €¦ While the context created by this function is the current context, you can call the UIGraphicsGetImageFromCurrentImageContext function to retrieve an image object based on the current contents of the context. That is what these functions are for: Making a new image by capturing some drawing.

Your situation is different: You already have an image, and you are a view that has been called upon to draw. This means that you already have a current context, and you need only to draw into it. So, don't create a context—just draw.

If you want to draw a UIImage, use a UIImageView. It was written to do that for you.

I intend to do a bit a custom drawing, and the docs indicate that because subclasses of UIImageView can't receive the drawRect message custom drawing should be done in subclasses of UIView. – Ben Collins Apr 10 '10 at 16:47 There are cases where you should draw an image directly. But you can just use the UIImageView as a subview of your own custom view.

– Paul Lynch Apr 10 '10 at 17:01.

The function you named drawImage should be named createScaledImage, as all it does is create scaledImage. To draw scaledImage, try scaledImage drawAtPoint:self.frame. Origin; You would be better served by sticking originalImage or scaledImage in a UIImageView with the contentMode set to UIViewContentModeScaleAspectFit.

UIImageView will basically do exactly what you have coded there, but it gets access to whatever caching and fast drawing Apple does behind the scenes.

I have a UIImageView showing a image that is larger than it's frame. It's set to rescale the image to fit it's frame. But, the image is scaled with a low quality filter.

I've read here that this is caused by it using a low interpolation quality. How can I get it's context to CGContextSetInterpolationQuality to kCGInterpolationHigh?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions