开发者

iPhone. How to change individual pixels of big CGImage inplace?

开发者 https://www.devze.com 2023-01-07 20:23 出处:网络
I use UIScrollView, which zooms and scrolls UIImageView, which contains UIImage, which take pixels from CGImage.

I use UIScrollView, which zooms and scrolls UIImageView, which contains UIImage, which take pixels from CGImage. Size of CGImage may be about 5000x2000 pixels 1) Is this a correct way to zoom and scroll big image?

Some logic may change periodically some region(rect) in t开发者_Python百科hat CGImage 2) How can i change individuall pixels in CGImage inplace without heawy processor usage (entire image recreation)?


my solution:

  • I create CGBitmapContext for storing big image at XRGB-format.
  • Subclass UIView for override drawRect: which represent my image

periodically updates do so:

  • update some rect
  • invoke [setNeedsDisplayInRect: rect]

in [drawRect: rect] do:

  CGContextRef g = UIGraphicsGetCurrentContext();
  CGImageRef imgAll = CGBitmapContextCreateImage( m_BmpContext );
  CGImageRef imgRect = CGImageCreateWithImageInRect( imgAll, rect );
  CGContextDrawImage( g, rect, imgRect );
  CGImageRelease( imgRect );
  CGImageRelease( imgAll );

and it's work fine for me

0

精彩评论

暂无评论...
验证码 换一张
取 消