Comments (4)
Much needed feature request from 2015.
from lodepng.
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.
@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.
@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)
- sdl2 HOT 6
- vulnerability Discover HOT 2
- what's mean of this define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS and when should i define it
- code optimization
- Че за хрень 64 бит компиляция HOT 1
- Sudden increase in build size HOT 1
- Memory leaks in function benchmark.
- SEGV on unknown address in function pngdetail. HOT 2
- How to get a JSON string from the encoded image ? HOT 3
- Expected speed? HOT 6
- Fix warnings: `conversion from 'size_t' to 'unsigned short', possible loss of data` HOT 2
- chunk type is restricted to the decimal values 65 to 90 and 97 to 122
- Veracode discovered a race condition
- Consideration for changing the License to public domain
- allocate "reserved_size" extra memory
- Lodepng fails to open valid png image HOT 4
- Clarification on "filter_palette_zero"
- lodepng crashes ntdll.dll
- Encoding from RGB 24 frame buffers handling stride / pitch
- Think the custom_zlib api is incomplete. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lodepng.