Hi Ken,

the problem was solved by checking bitsPerPixel and changed the pixel format
to GL_RGB, GL_UNSIGNED_BYTE

but, if the best combination of format / type is GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV so does it means we need to convert RGB / RGBA
to BGRA?

sorry for posting in cocoa list

2010/3/13 Ken Ferry <kenfe...@gmail.com>

> Hi,
>
> Please go down to the phrase "apps are rather fond of hardcoding bitmap
> formats" in the AppKit release notes.
> http://developer.apple.com/mac/library/releasenotes/cocoa/appkit.html
>
>
>>  If the latter I suspect that your file is not in the needed format.
>
> Does your image have alpha?
>
> format is bmp
>
>
> The file format is bmp, but there's also a pixel format, which is the
> layout of the uncompressed bytes in memory.  It is necessary to convert the
> data to the pixel format that you're telling GL the data is in.  You
> said GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV.
>
> The version you have involving NSImage is not safe either, it just happens
> to work today.
>
> -ken
>
> On Fri, Mar 12, 2010 at 10:03 AM, Ariel Feinerman 
> <arielfap...@gmail.com>wrote:
>
>> 2010/3/12 Alexander Spohr <a...@freeport.de>
>>
>> Exactly what does not work?
>> > The loading? Or the opengl command?
>> >
>> >
>> texture is corrupted with artifact on the screen  and sometimes
>>
>>
>> gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image
>> pixelsHigh], GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]);
>>
>> take an exception
>>
>> If the latter I suspect that your file is not in the needed format.
>> > Does your image have alpha?
>> >
>> > format is bmp
>>
>> there is of the matter is that messages -initWithCIImage and
>> -initWithFocusedViewRect
>> read bitmap date from offscreen window so image is rendered twice, isn`t
>> it?
>>
>> reference
>>
>> The image in the *ciImage* parameter must be fully rendered before the
>> receiver can be initialized. If you specify an object whose rendering was
>> deferred (and thus does not have any pixels available now), this method
>> forces the image to be rendered immediately. Rendering the image could
>> result in a performance penalty if the image has a complex rendering chain
>> or accelerated rendering hardware is not available.
>>
>> Is the way to get NSBitmapImageRep for OpenGL without offscreen rendering
>> image?
>>
>>       atze
>> >
>> >
>> >
>> > Am 12.03.2010 um 13:09 schrieb Ariel Feinerman:
>> >
>> > > // not work
>> > >
>> > > NSData *data = [NSData dataWithContentsOfFile: filename];
>> > >
>> > > NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData:
>> data];
>> > >
>> > >
>> > > as opposed to:
>> > >
>> > > // works fine
>> > >
>> > > NSImage *source = [[NSImage alloc] initWithContentsOfFile: filename];
>> > >
>> > > NSSize size = [source size];
>> > >
>> > > [source lockFocus];
>> > >
>> > > NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
>> > initWithFocusedViewRect:
>> > > NSMakeRect(0.0, 0.0, size.width, size.height)];
>> > >
>> > > [source unlockFocus];
>> > >
>> > >
>> > > // OpenGL commands
>> > >
>> > >
>> > > gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image
>> > > pixelsHigh], GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, [image
>> bitmapData]);
>> > >
>> > > why?
>> > >
>> > >
>> > > as opposed to
>> > > _______________________________________________
>> > >
>> > > 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:
>> > > http://lists.apple.com/mailman/options/cocoa-dev/atze%40freeport.de
>> > >
>> > > This email sent to a...@freeport.de
>> >
>> >
>> --
>> best regards
>> Ariel
>> _______________________________________________
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>>
>> This email sent to kenfe...@gmail.com
>>
>
>
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to