Giter VIP home page Giter VIP logo

Comments (4)

RandomErrorMessage avatar RandomErrorMessage commented on July 23, 2024 1

Much needed feature request from 2015.

from lodepng.

lvandeve avatar lvandeve commented on July 23, 2024

Hi,

This, along with better custom malloc support, is a big internal and API change, but planned at some point. Tho not soon for now.

To understand why the API is as-is: it was designed mainly for easy, one-function-call usage to load textures in games, in environments where memory usage is of no concern.

from lodepng.

hostilefork avatar hostilefork commented on July 23, 2024

@lvandeve Hm, does this really require an interface change? Couldn't the existing function just call two support functions--one that gets the width and height, and another that does the decoding into a buffer big enough for that width and height? Then clients who want to do their own allocation just call those two support functions directly?

I note that getting the width and height is already supported as lodpng_inspect(), so really this just means one needs to name the version that decodes into an existing buffer. Nothing in the interface has to change.

from lodepng.

kanryu avatar kanryu commented on July 23, 2024

@lvandeve I agree to @hostilefork .

This problem can be solved simply by customizing the part of decodeGeneric() which forcibly substitutes the buffer of lodepng_malloc () for out.

You may provide additional arguments to change the mode of operation, or create a new function to write to the existing buffer (that is not difficult at all).

Simply, I think that it should be treated as an external buffer and skip allocation, if out has a value.

However, what I have to advise is that the current export buffer has a clearly incorrect padding method.
It seems that lodepng_get_raw_size () is used in calculating the buffer size.

This is the correct calculation method:

return ((w * bpp / 8 + 3) / 4 * 4) * h ;

Each row of pixels must fulfill a 4-byte alignment.

Likewise, you should also manage bytesPerLine so that other buffer formats are acceptable.

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.