KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.33k stars 648 forks source link

JPEG to RGB bitmap conversion #1067

Closed mpatalberta closed 5 months ago

mpatalberta commented 5 months ago

Is their an example of converting from JPG bitmap to a RGB bitmap.

SaschaWillems commented 5 months ago

JPEG already stores image data as RGB(A).

Can you elaborate? How would this be relevant to this repository?

gpx1000 commented 5 months ago

https://github.com/libjpeg-turbo/libjpeg-turbo jpeg is a CODEC, that means that you'd want to use a library which can take the compressed jpeg and output an uncompressed bitmap.

mpatalberta commented 5 months ago

I was hoping to use the VulKan to provide a hardware JPG to BMP converter.

SaschaWillems commented 5 months ago

Vulkan does not know anything about codecs like JPEG, nor does it have any libraries to do such a conversion.

gpx1000 commented 5 months ago

Additionally, there'd be very little if any benefit of doing such a conversion in the graphics card. It is probably possible to use OpenCL or even Vulkan Compute shaders to do a conversion in the graphics card; but you wouldn't get much benefit from the extra effort, and you'd have to write a decompressor specific to your codec in a shader. If you were interested in more than one frame, you could look at Vulkan Video. However, for a single image, that's a lot of overhead for something the CPU is quite capable of.