tags:

views:

21

answers:

1

hi

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 that CGImage 2) How can i change individuall pixels in CGImage inplace without heawy processor usage (entire image recreation)?

A: 

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