Accelerate framework

  • Hi All. A simple question.
    Using the accelerate framework in iOS 5.1 I've imported the header Accelerate/Accelerate.h and in my code I'm using the line:

    uint_8 kernel = {-2, -2, 0, -2, 6, 0, 0, 0, 0};

    My problem is that I've got the error:

    "Use of undeclared identifier uint_8".

    Which is the header I've to use for uint_8?

    Thanks in advance for any answer.

    Luca.
  • uint_8?

    Do you mean uint8_t?

    On May 12, 2012, at 4:25 PM, Luca Ciciriello wrote:

    > Hi All. A simple question.
    > Using the accelerate framework in iOS 5.1 I've imported the header Accelerate/Accelerate.h and in my code I'm using the line:
    >
    > uint_8 kernel = {-2, -2, 0, -2, 6, 0, 0, 0, 0};
    >
    > My problem is that I've got the error:
    >
    > "Use of undeclared identifier uint_8".
    >
    > Which is the header I've to use for uint_8?
    >
    > Thanks in advance for any answer.
    >
    > Luca.
  • On May 12, 2012, at 3:25 AM, Luca Ciciriello wrote:

    > Using the accelerate framework in iOS 5.1 I've imported the header Accelerate/Accelerate.h and in my code I'm using the line:
    >
    > uint_8 kernel = {-2, -2, 0, -2, 6, 0, 0, 0, 0};
    >
    > My problem is that I've got the error:
    >
    > "Use of undeclared identifier uint_8".
    >
    > Which is the header I've to use for uint_8?

    Do you perhaps mean uint8_t?  Certainly, the Accelerate framework won't require you to use any type which it hasn't included the definition for.

    Regards,
    Ken
  • Yes You are right. It was a my stupid syntax error.

    L.

    On May 12, 2012, at 10:34 AM, Ken Thomases wrote:

    > On May 12, 2012, at 3:25 AM, Luca Ciciriello wrote:
    >
    >> Using the accelerate framework in iOS 5.1 I've imported the header Accelerate/Accelerate.h and in my code I'm using the line:
    >>
    >> uint_8 kernel = {-2, -2, 0, -2, 6, 0, 0, 0, 0};
    >>
    >> My problem is that I've got the error:
    >>
    >> "Use of undeclared identifier uint_8".
    >>
    >> Which is the header I've to use for uint_8?
    >
    > Do you perhaps mean uint8_t?  Certainly, the Accelerate framework won't require you to use any type which it hasn't included the definition for.
    >
    > Regards,
    > Ken
    >
    >
  • Now my problem is:
    How can I rebuild an UIImage from the output of the vImageConvolve_ARGB8888 elaboration?
    I can't find any code sample on this.

    L.
    On May 12, 2012, at 11:16 AM, Luca Ciciriello wrote:

    > Yes You are right. It was a my stupid syntax error.
    >
    > L.
    >
    > On May 12, 2012, at 10:34 AM, Ken Thomases wrote:
    >
    >> On May 12, 2012, at 3:25 AM, Luca Ciciriello wrote:
    >>
    >>> Using the accelerate framework in iOS 5.1 I've imported the header Accelerate/Accelerate.h and in my code I'm using the line:
    >>>
    >>> uint_8 kernel = {-2, -2, 0, -2, 6, 0, 0, 0, 0};
    >>>
    >>> My problem is that I've got the error:
    >>>
    >>> "Use of undeclared identifier uint_8".
    >>>
    >>> Which is the header I've to use for uint_8?
    >>
    >> Do you perhaps mean uint8_t?  Certainly, the Accelerate framework won't require you to use any type which it hasn't included the definition for.
    >>
    >> Regards,
    >> Ken
    >>
    >>

    >
  • Never used the framework but my first thought would be to create a CGImageRef which can take directly formatted data (I'm assuming that vImages are just a byte buffer) and then make a UIImage from there.

    What did you do to get a vImage from your UIImage in the first place?

    On May 12, 2012, at 8:26 PM, Luca Ciciriello wrote:

    > Now my problem is:
    > How can I rebuild an UIImage from the output of the vImageConvolve_ARGB8888 elaboration?
    > I can't find any code sample on this.
    >
    > L.
    > On May 12, 2012, at 11:16 AM, Luca Ciciriello wrote:
    >
    >> Yes You are right. It was a my stupid syntax error.
    >>
    >> L.
    >>
    >> On May 12, 2012, at 10:34 AM, Ken Thomases wrote:
    >>
    >>> On May 12, 2012, at 3:25 AM, Luca Ciciriello wrote:
    >>>
    >>>> Using the accelerate framework in iOS 5.1 I've imported the header Accelerate/Accelerate.h and in my code I'm using the line:
    >>>>
    >>>> uint_8 kernel = {-2, -2, 0, -2, 6, 0, 0, 0, 0};
    >>>>
    >>>> My problem is that I've got the error:
    >>>>
    >>>> "Use of undeclared identifier uint_8".
    >>>>
    >>>> Which is the header I've to use for uint_8?
    >>>
    >>> Do you perhaps mean uint8_t?  Certainly, the Accelerate framework won't require you to use any type which it hasn't included the definition for.
    >>>
    >>> Regards,
    >>> Ken
    >>>
    >>>

    >>

  • .. 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.
  • Grr .. again with the moderation for size .. can you not use rich text or something, it just makes a 6k message into a 50k one and this list has a really small max message size. Sending the mail yet again ..

    ---- original mail follows with the rich text turned into plain ------

    I said CGImageCreate, I think that's what you want, you certainly don't have a PNG, you have a bitmap of data, a raw buffer. I think you probably have the right data provider, that or use CGCreateDataProviderDirect() which looks the same for raw data but works directly with the buffer, but just plain CGImageCreate() looks like the function which takes raw bytes in an expressed format and makes the image. Definitely the PNGDataProvider is wrong, you don't have one of those.

    >
    > On May12, 2012, at 9:27 PM, Luca Ciciriello wrote:
    >
    > Now I've used the code: where
    >
    > CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, outData, (768 * 768 * 4), NULL);
    > CGImageRef test = CGImageCreateWithPNGDataProvider(provider, nil, true, kCGRenderingIntentDefault);
    >
    > where outData is the output of my EmbossEffect function.
    >
    > Here "provider" is valorized, but "test" is 0x0.
    > My suspect is that vImageConvolve_ARGB8888 is working with bitmap and a CGImageCreateWithPNGDataProvider is working with PNG, but I haven't found an equivalent function for Bitmap.
    >
    > Luca.
    >
    >
previous month may 2012 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today