The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Help with converting between SDL_Texture pixel formats?
Christian Leger
Guest

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 wrote:
Quote:
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?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Help with converting between SDL_Texture pixel formats?
Gabriele Greco
Guest

On Fri, Sep 19, 2014 at 11:53 PM, BadManiac wrote:
Quote:
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
Help with converting between SDL_Texture pixel formats?
Andreas Schiffler
Guest

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:

Quote:


On Fri, Sep 19, 2014 at 11:53 PM, BadManiac wrote:
Quote:
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






Quote:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org