FROM : Jean-Daniel Dupas
DATE : Fri Apr 25 20:45:47 2008
Le 25 avr. 08 à 18:12, David Duncan a écrit :
> On Apr 25, 2008, at 7:51 AM, Carter R. Harrison wrote:
>
>> This bug in my code has been driving me nuts for days, but I have
>> finally isolated the issue - only problem now is I don't understand
>> what I'm doing wrong.
>>
>> I have a CGImage that I want to get the raw data bytes for. My
>> code is below:
>>
>> CGImageRef sectionToCache =
>> CGImageCreateWithImageInRect(backingStore, CGRectMake(x, y, cx, cy));
>> NSLog(@"CGImage to cache has dimensions %d x %d and %d bytes per
>> row", CGImageGetWidth(sectionToCache),
>> CGImageGetHeight(sectionToCache),
>> CGImageGetBytesPerRow(sectionToCache));
>> CFDataRef dataRef =
>> CGDataProviderCopyData(CGImageGetDataProvider(sectionToCache));
>> NSLog(@"Length of cachedImage data: %d", CFDataGetLength(dataRef));
>>
>> When the code runs, the log spits out the following:
>>
>> CGImage to cache has dimensions 417 x 234 and 1668 bytes per row
>> Length of cachedImage data: 6672
>>
>> What is killing me here is that the CGImage has dimensions 417x234
>> and 1668 bytes per row. That to me means that the CFDataRef that I
>> am obtaining should be 390,312 bytes (234 x 1668). But the
>> CFDataRef is only 6,672 bytes which is nowhere close to what I
>> think I should be getting. So I must be doing something wrong in
>> trying to get the bitmap data, but I'm not sure what else to do and
>> I even found some Apple docs with an example doing the exact same
>> thing that I am doing. Can anybody provide some insight on this?
>> Thanks everybody.
>
> This seems to be related to the CGImageCreateWithImageInRect() call,
> but I can't imagine why. CGDataProviderCopyData() seems to work
> perfectly with an original image in my limited testing, so please
> file a bug (and let me know what the bug number is).
>
I didn't find any documentation about CGDataProviderCopyData() except
this comment in the header:
/* Return a copy of the data specified by provider. Returns NULL if a
* complete copy of the data can't be obtained (for example, if the
* underlying data is too large to fit in memory). */
What is the expected output format of the data it returns ?
DATE : Fri Apr 25 20:45:47 2008
Le 25 avr. 08 à 18:12, David Duncan a écrit :
> On Apr 25, 2008, at 7:51 AM, Carter R. Harrison wrote:
>
>> This bug in my code has been driving me nuts for days, but I have
>> finally isolated the issue - only problem now is I don't understand
>> what I'm doing wrong.
>>
>> I have a CGImage that I want to get the raw data bytes for. My
>> code is below:
>>
>> CGImageRef sectionToCache =
>> CGImageCreateWithImageInRect(backingStore, CGRectMake(x, y, cx, cy));
>> NSLog(@"CGImage to cache has dimensions %d x %d and %d bytes per
>> row", CGImageGetWidth(sectionToCache),
>> CGImageGetHeight(sectionToCache),
>> CGImageGetBytesPerRow(sectionToCache));
>> CFDataRef dataRef =
>> CGDataProviderCopyData(CGImageGetDataProvider(sectionToCache));
>> NSLog(@"Length of cachedImage data: %d", CFDataGetLength(dataRef));
>>
>> When the code runs, the log spits out the following:
>>
>> CGImage to cache has dimensions 417 x 234 and 1668 bytes per row
>> Length of cachedImage data: 6672
>>
>> What is killing me here is that the CGImage has dimensions 417x234
>> and 1668 bytes per row. That to me means that the CFDataRef that I
>> am obtaining should be 390,312 bytes (234 x 1668). But the
>> CFDataRef is only 6,672 bytes which is nowhere close to what I
>> think I should be getting. So I must be doing something wrong in
>> trying to get the bitmap data, but I'm not sure what else to do and
>> I even found some Apple docs with an example doing the exact same
>> thing that I am doing. Can anybody provide some insight on this?
>> Thanks everybody.
>
> This seems to be related to the CGImageCreateWithImageInRect() call,
> but I can't imagine why. CGDataProviderCopyData() seems to work
> perfectly with an original image in my limited testing, so please
> file a bug (and let me know what the bug number is).
>
I didn't find any documentation about CGDataProviderCopyData() except
this comment in the header:
/* Return a copy of the data specified by provider. Returns NULL if a
* complete copy of the data can't be obtained (for example, if the
* underlying data is too large to fit in memory). */
What is the expected output format of the data it returns ?
| Related mails | Author | Date |
|---|---|---|
| Carter R. Harrison | Apr 25, 16:51 | |
| Jean-Daniel Dupas | Apr 25, 17:57 | |
| Adam R. Maxwell | Apr 25, 18:10 | |
| David Duncan | Apr 25, 18:12 | |
| Carter R. Harrison | Apr 25, 18:25 | |
| Michael Vannorsdel | Apr 25, 20:16 | |
| Jean-Daniel Dupas | Apr 25, 20:45 | |
| David Duncan | Apr 25, 21:29 |






Cocoa mail archive

