qrmt / fpng-python Goto Github PK
View Code? Open in Web Editor NEWPython bindings for fpng
License: The Unlicense
Python bindings for fpng
License: The Unlicense
Greetings!
I try to wrap FPNG into Java via JNA.
Sorry for asking a maybe stupid question here. How is the Byte Array of the Image const void* pImage
provided?
My current understanding is:
/*
num_chans must be 3 or 4. There must be w*3*h or w*4*h bytes pointed to by pImage.
The image row pitch is always w*3 or w*4 bytes.
There is no automatic determination if the image actually uses an alpha channel, so if you call it with 4 you will always get a 32bpp .PNG file.
*/
// read the Demo PNG into an Image
BufferedImage image = ImageIO.read(inputStream);
// Create the w*4*h byte array
final byte[] byteArr = new byte[image.getWidth()*4*image.getHeight()];
for (int y=0; y<image.getHeight(); y++) {
for (int x=0; x<image.getWidth(); x++) {
int argb = image.getRGB(x, y);
final int alpha = 0xff & (argb >> 24);
final int red = 0xff & (argb >> 16);
final int green = 0xff & (argb >> 8);
final int blue = 0xff & (argb >> 0);
byteArr[x * 4 * y]= (byte) red;
byteArr[x * 4 * y + 1]= (byte) green;
byteArr[x * 4 * y + 2]= (byte) blue;
byteArr[x * 4 * y + 3]= (byte) alpha;
}
}
// Convert byte array to Pointer
Pointer pImage = new Memory(byteArr.length);
pImage.write(0, byteArr, 0, byteArr.length);
But it always crashes the Java VM when calling the Native Library.
Hi!
I found your python implementation of fpng, and I really want to use it in a project where I have to encode a lot of png images for a video stream. I can only use png images, so i'm stuck with cv2.imencode.
Sadly, I have little to no experience in C++ and I have failed trying to install fpng-python. I installed Visual Studio Build Tools 2019, and clone this repo exactly as said in the Readme, but when running python setup.py install
, I get the following error:
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\test-easy-install-1792.write-test'
Then, I try running python setup.py install --user
, and the installation starts, but I get another error (I have my computer in Spanish):
cl : Command-Line Warning D9002 : ignoring unknown option '-fno-strict-aliasing'
fpng.cpp
C:\Users\pcast\fpng-python\fpng\src\fpng.h(4): fatal error C1083: Cannot open filetype file: 'stdlib.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
I would really appreciate any help,
Pablo
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.