Tag: 缩放

OpenGL ES像素艺术 – 缩放

我无法在iPhone上的OpenGL Es 1.1上显示基于像素的艺术(认为复古瓷砖和艺术)。 使用8个字节(每行1个字节)表示块,每个位表示一个像素是否被设置。 例如,一个数字8: 0 0 0 0 0 0 0 0 -> 0 0 1 1 1 0 0 0 -> xxx 0 1 0 0 0 1 0 0 -> xx 0 1 0 0 0 1 0 0 -> xx 0 0 1 1 1 0 0 0 -> xxx 0 […]

在canvas上固定ios7压缩图像,旋转和缩放

我遇到了使用canvas在iOS7中被压扁的问题。 我发现以下post似乎正朝着正确的方向前进: HTML5 Canvas drawImage比率错误iOS 但是,我超越了绘制图像的简单情况,在绘制图像之前,我也在旋转和缩放上下文(对于带有EXIF方向数据的缩略图)。 代码会运行,但缩略图中没有图像数据。 我猜这与canvas旋转和缩放有关。 但是,我很难理解为什么当我的挤压因子是1(在没有错误的iOS设备上)时,缩略图不能正确创build。 这是我的完整的“onload()”代码: reader.onloadend = function(evt) { console.log('read file data!'); var tempImg = new Image(); console.log('created new Image'); tempImg.src = evt.target.result; console.log('set canvas to file'); // alert(this); tempImg.onload = function() { console.log('loaded tempImg'); var MAX_WIDTH = 450; var MAX_HEIGHT = 450; var tempW = tempImg.width; var tempH = […]

如何使用滚动视图缩放到中心?

我们之前实现了点击缩放function,现在我们决定使用图标来放大当前正在显示的内容的中心位置,而且我们希望重复使用我们用于缩放的代码,因为我们希望相同的效果,但是现在我们不知道要通过什么作为中心点。 我们正在使用 (CGRect)zoomRectForScale:(浮点)以Center:(CGPoint)为中心的比例 方法,用来接受来自手势识别器的中心cgpoint,我们用来进行点击缩放; 然而,由于我们不再使用手势识别器,我们将不得不找出通过它的cgpoint。 此外,这种方法适用于水龙头缩放,所以我不认为这是我们遇到问题的地方。 我们试着这样做 centerPoint = [scrollView contentOffset]; centerPoint.x += [scrollView frame].size.width / 2; centerPoint.y += [scrollView frame].size.height / 2; CGRect zoomRect = [self zoomRectForScale:newScale withCenter:centerPoint]; 哪个应该计算当前中心,然后将其传递给zoomRectForScale,但它不起作用(它放大到中心的右侧)。 我认为这个问题可能与我们在应用缩放之前传递图像的中心这一事实有关,也许我们应该通过缩放的中心。 有没有人有这方面的经验,或对我们如何计算中心有任何想法?

UIPinchGestureRecognizer分别在水平和垂直方向上缩放

当使用UIPinchGestureRecognizer时,在水平和垂直方向上检测/读取缩放比例的最佳方法是什么? 我看到这个post UIPinchGestureRecognizer在不同的x和y方向上缩放视图 但是我注意到这么一个看似常规的任务有很多来回走动,我不确定这是最好的答案。 如果完全不使用UIPinchGestureRecognizer来达到这个目的,那么检测两个不同方向的缩放比例的最好方法是什么?

使用UIPinchGestureRecognizer以缩放方向缩放视图

我需要一个缩放识别器,可以在x,y或两个方向上缩放,具体取决于捏的方向。 我查看了其他许多问题,他们只有部分答案。 这是我使用自定义UIPinchGestureRecognizer的完整解决scheme。

iOS平台上的HTML5canvas缩放问题

我一直在开发一个phonegap项目,试图构buildAndroid和iOS。 主要思路是访问手机库中保存的图片,将该图片保存到HTML img元素,然后将该img元素绘制到canvas上。 从那里,用户可以缩放和旋转图像。 我在Android上没有任何问题。 我已经使用仿真器和设备进行了testing,并且testing了大量的设备(不同的像素比例,密度等),结果的canvas转换总是给出预期的结果。 另一方面,iOS版本并没有那么成功。 缩放/旋转canvas看起来很好,直到我缩放canvas比原来的尺寸稍大(比原来大约4-5个像素)。 将canvas向上缩放后,canvas上绘制的图像会发生变化。 现在不用看现在看到的整个图像,我通常会在整个canvas上画出一小部分图像(通常是左上angular)。 我的canvas在HTML: <canvas id="sourceImgCanvas" width="200" height="200" style="z-index:1; position:absolute; left:5%; top:100px;"></canvas> 我从手机库收到的图像几乎总是太大,不适合手机屏幕。 我缩小图像并logging我缩小图像的比率(如果没有缩放发生,绘制比例为1,如果图像缩小到适合屏幕,则比例大于1)。 PhoneGap处理抓取手机库中的图片,我只是使用从照片返回的imageURI并将其设置为一个img元素Phonegap Camera API : // Called when a photo is successfully retrieved function onPhotoURISuccess(imageURI) { sourceImage = document.getElementById('sourceImg'); sourceImage.src = imageURI; //signal that user can manipulate photo with touch inputs b_editPhotoAllowed = true; } […]

Objective-C iOS裁剪图像使用缩放?

我想要使​​用这个代码来允许用户缩放和裁剪他们的图像在我的应用程序: https : //github.com/iosdeveloper/ImageCropper/tree/master/Classes/ImageCropper 代码片段 float zoomScale = 1.0 / [scrollView zoomScale]; CGRect rect; rect.origin.x = [scrollView contentOffset].x * zoomScale; rect.origin.y = [scrollView contentOffset].y * zoomScale; rect.size.width = [scrollView bounds].size.width * zoomScale; rect.size.height = [scrollView bounds].size.height * zoomScale; CGImageRef cr = CGImageCreateWithImageInRect([[imageView image] CGImage], rect); UIImage *cropped = [UIImage imageWithCGImage:cr]; CGImageRelease(cr); [delegate imageCropper:self didFinishCroppingWithImage:cropped]; 但是它并没有考虑到图片被旋转(我猜这是iPhone图片上的某种元数据)。 […]

closures缩放UIScrollView

有没有人知道使用UIScrollView时暂时closures缩放的方法? 我看到你可以禁用滚动使用以下内容: self.scrollView.scrollEnabled = false; 但是我没有看到类似的缩放命令。 有什么想法吗?

iOS的CAKeyFrameAnimation缩放在animation结束的闪烁

在关键帧animation的另一个testing中,我将沿着theImagepath移动UIImageView(称为theImage ),并在移动时将其放大,从而在path的末端产生两倍大的图像。 我最初的代码是通过这些元素来启动animation: UIImageView* theImage = …. float scaleFactor = 2.0; …. theImage.center = destination; theImage.transform = CGAffineTransformMakeScale(1.0,1.0); CABasicAnimation *resizeAnimation = [CABasicAnimation animationWithKeyPath:@"bounds.size"]; [resizeAnimation setToValue:[NSValue valueWithCGSize:CGSizeMake(theImage.image.size.height*scaleFactor, theImage.image.size.width*scaleFactor)]]; resizeAnimation.fillMode = kCAFillModeBackwards; resizeAnimation.removedOnCompletion = NO; CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.path = [jdPath path].CGPath; pathAnimation.fillMode = kCAFillModeBackwards; pathAnimation.removedOnCompletion = NO; CAAnimationGroup* group = [CAAnimationGroup animation]; group.animations = […]

用CGAffineTransform进行缩放并设置锚点

如果我正确地理解用CGAffineTransform缩放一个UIView锚定转换到其中心。 尤其是: self.frame = CGRectMake(0,0,100,100); self.transform = CGAffineTransformMakeScale(2, 2); NSLog(@"%f;%f;%f;%f", self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height); 打印: -50;-50;200;200 你如何创build一个使用特定锚点(比如0; 0)的CGAffineTransform比例?