English 中文(简体)
连接 UIGraphicsGetImageFromCurrentImageContext and部
原标题:Connection between UIGraphicsGetImageFromCurrentImageContext and drawInrect

我已经找到了以下法典,以便重新使用UIImage:

CGSize newSize = CGSizeMake(self.image.size.width*0.25, self.image.size.height*0.25);
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[self.image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

但是,我不理解一些两点。

第一,Im试图将原图像重新定位为原面积的25%,但这一方法将其减少到原面积的50%。 为什么?

<代码>drawInRect和>之间有何联系。 页: 1 UIGraphicsGetImageFromCurrentImageContext 超过目前的形象要求drawInRect

如果有人能帮助我了解细节上的内容,我将不胜感激。

提前感谢。

最佳回答

首先,由于考试是“再开门”的,你应将比额表设定为1.0,或仅限x2。

UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0);

如果你打电话UIGraphics BeginImageContext,任何油漆工作都将产生Context

http://strong>drawInRect, 载于您的法典中,它描绘了这个背景的形象,但并非多余。

或者你可以去除,你就有一个空洞的形象。

最后,你可以从背景中合并“UIImage”。

UIGraphicsGetImageFromCurrentImageContext();

刚获得UIImage 您所做的工作(背景)

如果你不把形象推回来,就会赢得任何变化。

self.image = UIGraphicsGetImageFromCurrentImageContext();
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签