Help with converting between SDL_Texture pixel formats?

Hi,

I’ve recently started playing around with SDL for a hobby project of mine, replacing my old 16 bit software blitting library. And I’ve come across a problem I’m hoping someone here can help me with.

I have a block of raw pixel data in BGR888 format, and I want to convert it to a ARGB8888 texture. I tried SDL_ConvertPixels but it doesn’t work in the way I need it to. I need each pixel to be “expanded” from three byte to four byte. SDL_Convert pixels does it on a row by row basis.

So is there some clever SDL function I’m missing that will do this or willl I have to break out the old assembler? :slight_smile:

Hi,

I’m not familiar enough with the SDL library functions for conversions to
answer the first part of your question, however I would recommend you
complete your task in C rather than in assembler. Unless you are totally
proficient in asm, then never mind ^_^On Fri, Sep 19, 2014 at 5:53 PM, BadManiac <martin_maniac at hotmail.com> wrote:

Hi,

I’ve recently started playing around with SDL for a hobby project of mine,
replacing my old 16 bit software blitting library. And I’ve come across a
problem I’m hoping someone here can help me with.

I have a block of raw pixel data in BGR888 format, and I want to convert
it to a ARGB8888 texture. I tried SDL_ConvertPixels but it doesn’t work
in the way I need it to. I need each pixel to be “expanded” from three byte
to four byte. SDL_Convert pixels does it on a row by row basis.

So is there some clever SDL function I’m missing that will do this or
willl I have to break out the old assembler? [image: Smile]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi,

I’ve recently started playing around with SDL for a hobby project of mine,
replacing my old 16 bit software blitting library. And I’ve come across a
problem I’m hoping someone here can help me with.

I have a block of raw pixel data in BGR888 format, and I want to convert
it to a ARGB8888 texture. I tried SDL_ConvertPixels but it doesn’t work
in the way I need it to. I need each pixel to be “expanded” from three byte
to four byte. SDL_Convert pixels does it on a row by row basis.

Use SDL_CreateRGBSurfaceFrom with the appropriate parameters on your
BGR888 raw data and blit the result to a SDL_CreateRGBSurface with format
ARGB8888.On Fri, Sep 19, 2014 at 11:53 PM, BadManiac <martin_maniac at hotmail.com> wrote:


Bye,
Gabry

Wouldn’t this just do it behind the scenes?
SDL_Texture* texture = SDL_CreateTexture(renderer, pixelData,
SDL_PIXELFORMAT_BGR888, SDL_TEXTUREACCESS_STATIC, w, h);
(see https://wiki.libsdl.org/SDL_CreateTexture)On 11/13/2014 1:06 AM, Gabriele Greco wrote:

On Fri, Sep 19, 2014 at 11:53 PM, BadManiac <martin_maniac at hotmail.com <mailto:martin_maniac at hotmail.com>> wrote:

Hi,

I've recently started playing around with SDL for a hobby project
of mine, replacing my old 16 bit software blitting library. And
I've come across a problem I'm hoping someone here can help me with.

I have a block of raw pixel data in BGR888 format, and I want to
convert it to a ARGB8888 texture. I tried SDL_ConvertPixels but it
doesn't work in the way I need it to. I need each pixel to be
"expanded" from three byte to four byte. SDL_Convert pixels does
it on a row by row basis.

Use SDL_CreateRGBSurfaceFrom with the appropriate parameters on your
BGR888 raw data and blit the result to a SDL_CreateRGBSurface with
format ARGB8888.


Bye,
Gabry


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org