CoreGraphics图像调整大小 [英] CoreGraphics Image resize

查看:168
本文介绍了CoreGraphics图像调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码来自Apple的WWDC 2011 Session 318 - iOS Performance in Depth,并使用CoreGraphics从服务器托管的图像创建缩略图。

This code is from Apple's WWDC 2011 Session 318 - iOS Performance in Depth and uses CoreGraphics to create thumbnails from server hosted images.

CGImageSourceRef src = CGImageSourceCreateWithURL(url);
NSDictionary *options = (CFDictionaryRef)[NSDictionary 
dictionaryWithObject:[NSNumber numberWithInt:1024
forKey:(id)kCGImageSourceThumbnailMaxPixelSize];

CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src,0,options);
UIImage *image = [UIImage imageWithCGImage:thumbnail];
CGImageRelease(thumbnail);
CGImageSourceRelease(src); 

但它不起作用且文档没有真正帮助。在 iOS 文档 CGImageSource CGImageSourceRef CGImageSourceCreateThumbnailAtIndex 可用

But it doesnt work and the docs don't really help. In the iOS docs CGImageSource CGImageSourceRef CGImageSourceCreateThumbnailAtIndex are available


在Mac OS X v10.4或更高版本中

in Mac OS X v10.4 or later

我怎样才能让它发挥作用?

How can I get this to work?

编辑

这些是我得到的编译器错误:

These are the compiler errors I'm getting:


  • 使用未声明的标识符'CGImageSourceRef'

  • 使用未声明的标识符'kCGImageSourceThumbnailMaxPixelSize'

  • 使用未声明的标识符'src'

  • 函数'CGImageSourceCreateThumbnailAtIndex'的隐式声明无效in C99

  • 函数'CGImageSourceRelease'的隐式声明在C99中无效

  • 函数'CGImageSourceCreateWithURL'的隐式声明在C99中无效

  • Use of undeclared identifier 'CGImageSourceRef'
  • Use of undeclared identifier 'kCGImageSourceThumbnailMaxPixelSize'
  • Use of undeclared identifier 'src'
  • Implicit declaration of function 'CGImageSourceCreateThumbnailAtIndex' is invalid in C99
  • Implicit declaration of function 'CGImageSourceRelease' is invalid in C99
  • Implicit declaration of function 'CGImageSourceCreateWithURL' is invalid in C99

推荐答案

男生错误。

未添加 #import< ImageIO / ImageIO.h>

这篇关于CoreGraphics图像调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆