Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loading 8bpp and lower color images without dithering the image and changing the palette #175

Closed
a740g opened this issue Sep 11, 2022 · 0 comments · Fixed by #180
Closed
Labels
bug Something isn't working

Comments

@a740g
Copy link
Contributor

a740g commented Sep 11, 2022

QB64-PE uses stb_image & dr_pcx libraries to load all image files when requests are made using _LOADIMAGE.

Both stb_image and dr_pcx automatically de-palettizes the image on load. So, there is no way to tell what kind of color information these images had after the image data is received from these libraries.

See nothings/stb#510 and nothings/stb#1124

So when the user loads a 24-bit image using _LOADIMAGE("my_image.jpg", 256), then:

  1. The image is converted to 32bpp by stb_image while loading
  2. Once we have the 32bpp data, _LOADIMAGE converts the image to 8bpp and applies ordered dithering
  3. An adaptive palette is created or the image is remapped to QB64-PE master palette (depending on the _LOADIMAGE bpp parameter)

This results in an acceptable 8-bit image quality.

However, when the user loads an 8-bit palettized image using _LOADIMAGE("my_image.gif", 256), stb_image de-palettizes the image and the same steps are applied to the data (as noted above). Hence, there are two side-effects:

  1. The color palette is not the same compared to the original image it was loaded from
  2. Some artifacts may be seen in the final image due to the ordered dithering step
@a740g a740g added the bug Something isn't working label Sep 12, 2022
a740g added a commit to a740g/QB64pe that referenced this issue Sep 17, 2022
@a740g a740g mentioned this issue Sep 17, 2022
@a740g a740g linked a pull request Sep 17, 2022 that will close this issue
a740g added a commit that referenced this issue Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant