.. got moderated for size .. so I'll send again .. I think perhaps the 
formatted code in your mail was on the ragged edge for the list ... Scott feel 
free to axe the original version of this message if you see it when doing the 
moderation queue ... 

---- original message ------`

I'm guessing from my quick read of a few pages of the documentation whilst 
watching formula1 but I don't think you can do that. You went through a 
CGImageRef,  I would expect you have to go back through it. I don't think 
UIImage will take what looks like a pretty raw buffer, it's only for a limited 
set of formats. I, were I trying this, would be looking at CGImageCreate with a 
CGDataProviderRef which just rips right out of your data buffer and then make a 
UIImage with that.  

This is me guessing but it's what I'd try if I were doing this. I don't know if 
there is a better way to get the initial bytes by the way, there may be, slow 
drawing into a bitmap context but quite possibly right. Will be interested to 
see other replies here. 

> Me to, first time I use the accelerate framework and I haven't found any 
> sample code in order to help me in my first step.
> 
> Here the code I use: 
> 
>     CGImageRef inImage = [[UIImage imageNamed:@"estate3.jpg"] CGImage];
>     CGContextRef cgctx = CreateARGBBitmapContext(inImage);
>     
>     // Get image width, height. We'll use the entire image.
>     size_t w = CGImageGetWidth(inImage);
>     size_t h = CGImageGetHeight(inImage);
>     CGRect rect = {{0,0},{w,h}};
>     
>     // Draw the image to the bitmap context. Once we draw, the memory 
>     // allocated for the context for rendering will then contain the 
>     // raw image data in the specified color space.
>     CGContextDrawImage(cgctx, rect, inImage);
>     
>     void *inData = CGBitmapContextGetData (cgctx);
>     void *outData = malloc(768 * 768 * 4);
>     unsigned int inRowBytes    = 768 * 4;
>     unsigned int outRowBytes   = 768 * 4;
>     unsigned int height        = 768;
>     unsigned int width         = 768;
>     unsigned int kernel_height = 3;
>     unsigned int kernel_width  = 3;
>     int divisor = 2;
>     vImage_Flags flags = kvImageLeaveAlphaUnchanged;
>     
>     
>     int res = EmbossEffect(inData, inRowBytes, outData, outRowBytes, height, 
> width, kernel_height, kernel_width, divisor, flags);
>     if(res != kvImageNoError)
>     {
>         NSLog(@"Manipulation Error");
>     }
> 
>    No exit error here. Then … Here
> 
>       NSData *imgData = [[NSData alloc] initWithBytes:outData length:(768 * 
> 768 * 4)];
> 
>    UIImage *retrivedImage = [UIImage imageWithData:imgData];  /// 1)
>    [imageView setImage:retrivedImage];
>       
>    Here in 1) the "retrievedImage" is 0x0.
> 
> The function EmbosEffect is:
> 
> int EmbossEffect(void         *inData,
>                  unsigned int inRowBytes,
>                  void         *outData,
>                  unsigned int outRowBytes,
>                  unsigned int height,
>                  unsigned int width,
>                  unsigned int kernel_height,
>                  unsigned int kernel_width,
>                  int          divisor,
>                  vImage_Flags flags)
> {
> 
>     int16_t kernel[]   = {-2, -2, 0, -2, 6, 0, 0, 0, 0};
>     vImage_Buffer src  = { inData, height, width, inRowBytes };
>     vImage_Buffer dest = { outData, height, width, outRowBytes };
>     unsigned char bgColor[4] = { 0, 0, 0, 0 };
>     vImage_Error  err = 0;
>     
>     err = vImageConvolve_ARGB8888(&src,                              //const 
> vImage_Buffer *src
>                                   &dest,                             //const 
> vImage_Buffer *dest,
>                                   NULL,
>                                   0,                                 
> //unsigned int srcOffsetToROI_X,
>                                   0,                                 
> //unsigned int srcOffsetToROI_Y,
>                                   kernel,                            //const 
> signed int *kernel,
>                                   kernel_height,                     
> //unsigned int
>                                   kernel_width,                      
> //unsigned int
>                                   divisor,                           //int
>                                   bgColor,
>                                   flags | kvImageBackgroundColorFill 
> //vImage_Flags flags 
>                                   );
> 
>     return err;
> }
> 
> Luca.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to