Lightweight C++ frontend to libjpeg-turbo. Distributed under GPL v.3.0 license.
Dependencies: see dep/README.md
Lightweight C++ frontend to libjpeg turbo
License: GNU General Public License v3.0
In TjDeCompressor.h we call:
tjDecompressHeader3(tjDeCompressor_,
jpgImg,
size,
&width,
&height,
&jpegSubsamp,
&colorSpace))
then later call:
if(tjDecompress2(tjDeCompressor_, jpgImg, size, img_.DataPtr(),
width, pitch, height, colorSpace, flags))
The problem is that a turbo jpeg colorspace (TJCS) is not the same as a turbo jpeg pixel format (TJPF). The TJCS (colorSpace) returned by tjDecompressHeader3 cannot be passed as a TJPF to tjDecompress2.
It seems the pixel format isnt actually stored in the header, or at least isnt exposed by tjDecompressHeader3 and there seems to be no other header related functions. This means you must know the pixel format in advance and pass it directly to the Decompress() function along with the data pointer, size, flags and pitch.
( For TJCS vs TCPF: https://cdn.rawgit.com/libjpeg-turbo/libjpeg-turbo/master/doc/html/group___turbo_j_p_e_g.html#ga4f83ad3368e0e29d1957be0efa7c3720 )
Add a method that accepts a JPEGImage& as the compression target
Should be inlined to avoid multiple definitions:
In JPEGImage.h:
The UncompressedSize() function returns the number of components per pixel * number of pixels.
To be consistent with JPEGSize() it should be number of components per pixel * number of pixels * sizeof(pixel component), where in this case pixel component is float32.
It may simply be a case of multiplying by 4, as I dont see any capability in tjpp for non float32 based images, but in case supporting that is planned for future perhaps it needs a more clever approach. (I didnt check whether lib turbo jpeg supports non-float images, i guess if it doesnt then the answer is simply multiply by 4 appropriately in the UncompressedSize() function)
This line in JPEGImage reset() is suspicious, I think it should be corrected for the same reasons as #6, tjBufSize returns bytes whereas w * h * NumComponents(pf) is not bytes
const size_t sz = std::max(tjBufSize(w, h, s),
static_cast< unsigned long >(
w * h * NumComponents(pf)));
At the end of reset() you should insert the following line so that the size is reported correctly by JPEGSize()
jpegSize_ = sz;
Pixel format is now a required parameter: so pf cannot have a default argument anymore.
replace:
//read data from header case
Image DeCompress(unsigned char* jpgImg,
size_t size,
int flags = TJFLAG_FASTDCT,
int pf = -1,
int pitch = 0) {
with:
//read data from header case
Image DeCompress(unsigned char* jpgImg,
size_t size,
int pf,
int flags = TJFLAG_FASTDCT,
int pitch = 0) {
Use TJPF_* everywhere, the Image class is supposed to be used only within this jpeg lib wrapper framework so the pixel format must match the jpeg format.
SyncQueue should have its own separate project
Otherwise Time conflicts with an Xlib typedef (would be helpful if the X guys used a namespace too!)
Add serializer/de-serializer for JPEGImage in a format compatible with the srz::* framework currently part of zrf. This allows images to be streamed for e.g. remote visualization tasks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.