ios - fast method to get RGB data from UIImage (photo library) -


I want to get the RGB representation of the picture stored in the photo library (a Aelssset) iOS (iOS 8 SDK). I already get to try this method:

  • CGContext attract CGImage [ALAssetRepresentation fullScreenImage]
  • with a CGImage from ALAsset.

This method works, I get an indicator for RGB data, but it is really slow (it has 2 conversions). The ultimate goal is to load the image quickly in an open gallon texture.

my code to get an image from the photo library

  ALAsset * currentPhotoAsset = (ALAsset *) [self.photoAssetList objectAtIndex: _currentPhotoAssetIndex]; Elassette Report * Representation = [Current PhotoAsset Default Report]; // -> Really slowed UIImage * currentPhoto = [UIImage imageWithCGImage: [fullscreenized representation]];  

My code to draw on CGContext:

  CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB (); NSUInteger bytesPerPixel = 4; NSUntaser bytesprero = BitParxel * TexturedWidth; NSUInteger BitsStechnicPoint = 8; CGContextRef reference = CGBitmapContextCreate (textureData, textureWidth, textureHeight, bitsPerComponent, bytesPerRow, colorspace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease (colorspace); // -> This is really slow CGContextDrawImage (reference, CGRectMake (0, 0, textureWidth, textureHeight), cgimage); CGContextRelease (reference);  

You can not do this, but if you think I'll find a way glad to hear about it

you image (JPG, PNG ...) need to be uncompressed, which is usually a Sijiaimej ( UIImage ), but you do not have permission to get the data pointer directly from CGImage , but you can copy them The need (call actually attracted slow). However, if target size and format are similar to source, then this operation should be quite fast as the data should be copied more or less. On the other hand, if your textureWidth and textureHeight , then the different image dimensions need to be inserted in those pixels and this function can also be slow down several times.

The only way to see this is that some libraries have to decompress the image directly from the image and get the data indicator of that image. But I had no performance problem to load image texture (use of background thread).

Even if you are not doing anything like that, how am I already using it so that the size of the image is obtained, then the power of POT two) the image size filling width and height again I create a blank texture with those sub dimensions and call the sub image to pass the original image data to the texture. I use a custom texture square to maintain it which has a texture (textured) texture coordinates, so the correct part of the texture is drawn for the frame buffer, then this square is extended to support atlasing. , Which is usually what you want to do while working with multiple images (texture).

I hope this information will help you in any way ...


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -