img4d 0.0.2

PNG decoder/encoder in Dlang.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

img4d StatusStatus

PNG images Decoder/Encoder for D language. It's defective implemention and I cannot guarantee the operation. Please see current status on commit page

Please feel free to throw PRs or issues.

Examples

decode, convert to grayscale and encode

import img4d;
import std.stdio,
       std.range,
       std.algorithm.iteration;

int main(){
    Header hdr;
    int[][][] actualData;

    // start decode
    Pixel colorPix = hdr.load("png_img/lena.png");
    if(colorPix.length == 0) {return 0;}
    colorPix.each!(n  => actualData ~= n.chunks(lengthPerPixel).array);  
    
    // convert to grayscale
    Pixel grayPix = actualData.rgbToGrayscale;
    beforeEncode.colorType = colorTypes.grayscale;
    
    // start encode
    bool encodedData = hdr.save(grayPix, "png_img/encoded_lena.png");

    return 0;
}

Package

img4d

img4d_lib.decode

img4d_lib.encode

img4dlib.colorspace

img4d_lib.edge

## img4d

  • ref auto load(ref Header header, string filename)
  • ubyte[] save(ref Header header, ref Pixel pix, string filename)
  • auto canny(T)(T[][] actualData, int tMin, int tMax)
  • ref auto rgbToGrayscale(T)(ref Header header, ref T[][][] color)
  • pure auto toBinary(T)(ref T[][] gray, T threshold=127)
  • pure auto toBinary(T)(T[][] array)
  • pure auto differ(T)(ref T[][] origin, ref T[][] target)
  • pure auto mask(T)(ref T[][][] colorTarget, ref T[][] gray)

img4d_lib.decode

  • Header readIHDR(ubyte[] header) Set Header struct and Return its struct
  • Params: ubyte[] header: Header byte-data
  • int byteToInt(T)(T[] data) Return ChunkData-length(Convert byte array to int)
  • string byteToString(T)(T[] data) Return Chunk Type(Convert byte array to string)
  • ubyte[] readIDAT(ubyte[] data) Calculate CRC and Return IDAT Chunk-Data
  • Params: ubyte[] data : IDAT array expect for Chunk-Data-Size
  • void crcCheck(ubyte[] crc, in ubyte[] chunk) The function of CRC calculation
  • Params ubyte[] crc : The CRC code at the end of the chunk ubyte[] chunk : Byte array to be CRC calculated
  • int paethPredictor(int left, int upper, int upperLeft) Calculate and Return Paeth-Predictor
  • auto normalizePixelValue(T)(T value) Return the value which are subtracted 256 if it exceeds 256
  • int[][] inverseFiltering(string op, string inequality, string inverseOp)(ubyte[][] data)
  • int[][] parse(ref Header info, string filename)

img4d_lib.encode

  • ubyte[] makeIHDR(in Header info) Return IHDR which required for encoding
  • Params: Header info : arranged Header
  • ubyte[] makeIDAT(T)(T[][] actualData, in Header info) Return IDAT which required for encoding
  • Params: T actualData : IDAT chunk data Header info : arranged Header
  • ubyte[] makeAncillary() Not implemented
  • ubyte[] makeIEND() Return IEND which required for encoding
  • auto makeCrc(in ubyte[] data) Calculate and Return CRC value
  • auto sumScanline(ubyte[][] src) Cast to int[] and Calculate sum every horizontal line
  • auto chooseFilterType(ref Header header, ref Pixel pix) Choose optimal filter and Return filtered pixel

img4d_lib.filter

  • pure ref auto inverseSub(ref ubyte[][] scanline)
  • pure ubyte[][] sub(ref ubyte[][] src) Calculate and Return Sub filter(Difference from left pixel)
  • pure ubyte[][] up(ref ubyte[][] src)
  • pure ubyte[][] neighborDifference(ubyte[][] src) Calculate difference neighbor pixel
  • pure ref auto joinVertical(T)(ref T[][] src) Make array vertical
  • auto inverseUp() Not implemented
  • auto ave() Not implemented
  • auto inverseAve() Not implemented
  • auto paeth() Not implemented
  • auto inversePaeth() Not implemented

img4dlib.colorspace

  • ref auto toGrayscale(T)(ref T[][][] color) Convert to grayscale by weighting

img4d_lib.edge

  • auto differential(T)(T[][] array, T[][] filter)
  • auto gradient(T)(T[][] Gr, T[][] Gth)
  • auto hysteresis(T)(T[][] src, int t_min, int t_max)
Authors:
  • DYGV
Dependencies:
none
Versions:
0.0.3 2019-Jan-17
0.0.2 2019-Jan-16
0.0.1 2018-Dec-25
~master 2019-Jan-17
~feature 2018-Dec-31
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
0.0
Short URL:
img4d.dub.pm