Wrapping stb single-file public domain C libraries for Java image reading, writing and resizing

The project provides an image reading, writing and resizing Java API, using the Java Native Interface (JNI), for the “stb single-file public domain C libraries“. In particular, the following C programming language header files which enable very fast reading, writing and resizing of images are wrapped:

  • “stb_image.h”
  • “stb_image_write.h”
  • “stb_image_resize.h”

The code is available at:

https://github.com/Kyaw-Kyaw-Htike/Wrapping-stb-single-file-public-domain-C-libraries-for-Java-image-reading-writing-and-resizing

Usage example 1 (reading and displaying image):

String fpath = "somePic.png";
Matk m = STBimage.imread(fpath);
m.imshow();

Usage example 2 (reading, resizing and displaying the original and resized images):

String fpath = "someImage.png";
Matk img = STBimage.imread(fpath);
Matk img2 = STBimage.imresize(img, 3);
img.imshow();
img2.imshow();

Usage example 3 (reading, resizing and saving the resized image):

String fpath = "inputImage.png";
Matk img = STBimage.imread(fpath);
Matk img2 = STBimage.imresize(img, img.ncols()*2, img.nrows()*2);
String fpath_out = "outputImage.png";
STBimage.imwrite(fpath_out, img2);