Giter VIP home page Giter VIP logo

Comments (5)

lvandeve avatar lvandeve commented on June 25, 2024

Hi,

I tried out decoding it with the "showpng" example (examples/example_sdl.cpp), and it looks correct to me.

The image has an alpha channel though, a translucent background. Which part has the wrong color when you view it, the gear, or the background?

Thanks!

from lodepng.

missinglucy avatar missinglucy commented on June 25, 2024

https://blog.littlevgl.com/2018-10-05/png_converter
see the image, red is converted to blue, blue is converted to read

from lodepng.

lvandeve avatar lvandeve commented on June 25, 2024

Which color should the gear have? For me it's blue with gray

from lodepng.

missinglucy avatar missinglucy commented on June 25, 2024

I read from https://lodev.org/lodepng/, found the words like below:
So I change my code fork from 'https://blog.littlevgl.com/2018-10-05/png_converter'. change R to B, B to R, Then I display color right to my pc now.

    //c = LV_COLOR_MAKE(img_argb[i].red, img_argb[i].green, img_argb[i].blue);
    c = LV_COLOR_MAKE(img_argb[i].blue, img_argb[i].green, img_argb[i].red);

Q: The image is wrong when using LodePNG with BITMAPs in Visual Studio or win32, or with BMP images.

A: LodePNG uses raw buffers with RGBA or RGB pixels in the common order RGBARGBARGBA... or RGBRGBRGBRGB..., from top to bottom, without any special byte boundaries. BMP images and bitmaps in win32 use a different format. They do three things differently:

Instead of being from top to bottom, it goes from bottom to top (upside down).
Instead of using the order red, green, blue, it uses the order blue, green, red, or BGRBGRBGR..., (can result in wrong colors).
It has a limitation where rows always must be a multiple of 4 bytes, so if the width of the image is not a multiple of 4 some unused bytes are introduced at the end of each row (can result in a skewed image).

All of this are related to how BMP works, not how PNG or LodePNG work. When you're working with BMP, you need to take each of these three things into account and convert this to/from the buffer format that LodePNG uses. Also check out the png2bmp and bmp2png samples, which already do this.


from lodepng.

lvandeve avatar lvandeve commented on June 25, 2024

Indeed! Thanks for pointing to BITMAP.

Indeed those examples show how to convert between BMP and PNG, direct links to them:

https://github.com/lvandeve/lodepng/blob/master/examples/example_png2bmp.cpp
https://github.com/lvandeve/lodepng/blob/master/examples/example_bmp2png.cpp

from lodepng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.