简体   繁体   English

遮罩后图像看起来模糊

[英]After masking Image looks blur

I am developing one game where I want to magnify the image where magnifier image is placed. 我正在开发一款游戏,在其中我想放大放置放大镜图像的图像。 For that I am using the concept of masking. 为此,我使用掩膜的概念。 After masking I am zooming the image but looks blur. 遮罩后,我正在缩放图像,但看起来模糊。 And I want image should be clearer like we r looking through rifle magnifier. 而且我希望像通过步枪放大镜看时图像应该更清晰。 So if any one have solution then kindly reply 因此,如果有人有解决方案,请回复

are you sure that the problem is the masking? 您确定问题在于掩蔽吗?

perhaps your resources are too low resolution? 也许您的资源分辨率太低? high resolution images scaled down always look better than low resolution images scaled up. 缩小的高分辨率图像总是比放大的低分辨率图像更好。 Maybe you need to look at the problem backwards... so that your image when looking through the rifle magnifier [scope?] is viewed at a 1:1 resolution and when not viewed through the scope it is zoomed out (1:2 resolution?). 也许您需要向后看问题...以便通过步枪放大镜[scope?]观看时,您的图像以1:1的分辨率查看,而当不通过示波器进行查看时,图像将被缩小(1:2分辨率?)。 so this way your 'normal' mode is the zoomed out mode and the "magnified view" is actually just the image at 1:1. 因此,您的“正常”模式就是缩小模式,而“放大视图”实际上只是1:1的图像。

If you have A UIImage whose size is 293x184 but you create a UIImageView with an initial size of 40x30, the iPhone SCALES the UIImage to fit according to the property: contentMode. 如果您有一个UIImage,其尺寸为293x184,但是创建的UIImageView的初始尺寸为40x30,则iPhone将根据属性contentContent对UIImage进行缩放。 Default contentMode is: UIViewContentModeScaleToFill, which scales your image. 默认的contentMode是:UIViewContentModeScaleToFill,它可以缩放图像。

So even though you started with a large image, it is now only 40x30 and rendered at 40x30. 因此,即使您从大图像开始,它现在只有40x30并以40x30渲染。 When you zoom it is STILL 40x30, but rendered at some larger size which is causing the blur. 缩放时仍为40x30,但以较大尺寸渲染会导致模糊。

One solution would be to replace the image after the zoom, then you would have a completely new UIImage at full resolution. 一种解决方案是在缩放后替换图像,然后您将拥有一个全分辨率的全新UIImage。

[self.view setFrame:reallyBigFrame];
[self.view setImage:newUIImage];

Another would be initially place the UIImage in a full size 293x184 UIImageView, then use an AffineTransform to scale it down: 另一个方法是最初将UIImage放置在全尺寸293x184 UIImageView中,然后使用AffineTransform将其缩小:

view.transform = CGAffineTransformScale(view.transform, 0.25, 0.25);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM