FORMfields


FORMfields.FfPngHelper

Class FfPngHelper

FfPngHelper

public class FfPngHelper

FfPngHelper provides helper functions for dynamically creating PNG images that used by the ImageVerificationField. PNG has become the the web image of choice and is supported by all modern web browsers. The spec can be found at PNG Spec

Since:
FORMfields v3.0

Method Summary
array

genPngChunk(int len, string chunkType, mixed chunkData, array PNG)

Generates a PNG chunk.

array

genVerificationImage(int code)

Generates a scrambled PNG image of the supplied code.

array

generatePng(array gzImage, int width, int height)

Returns the binary data of an 8 bit grayscale PNG.

array

getIdat(string filename)

Returns the IDAT area of the PNG image at filename.

array

scrambleScanLine(array line)

Returns a scrambled scanline by randomly changing the color of random pixels.

Method Detail

genPngChunk

public array genPngChunk(int len, string chunkType, mixed chunkData, array PNG)

Generates a PNG chunk.

Parameters:
len - the length of the PNG chunk
chunkType - the PNG chunk type
PNG - chunk data
Returns:
the encoded PNG chunk
Since:
FORMfields v3.0

genVerificationImage

public array genVerificationImage(int code)

Generates a scrambled PNG image of the supplied code. Scramble Steps:
1. Generates a single large image comprised of smaller images.
2. Digits are randomly placed throughout the larger image.
3. Noise is generated to deter image recognition.
Possible Enhancements: Add strikethrough lines, color, letters; rotate digits.

Parameters:
code - a 6 digit number that will be drawn
Returns:
a scrambled PNG image of the supplied code
Since:
FORMfields v3.0

generatePng

public array generatePng(array gzImage, int width, int height)

Returns the binary data of an 8 bit grayscale PNG. The spec can be found at PNG Spec

Parameters:
gzImage - array of gzcompress encoded image data
width - the width of the image in pixels
height - the height of the image in pixels
Returns:
the binary PNG image data
Since:
FORMfields v3.0

getIdat

public array getIdat(string filename)

Returns the IDAT area of the PNG image at filename. The FfPngHelper uses this method to combine several images in creating the verification image.

Parameters:
filename - path to the PNG image
Returns:
the binary IDAT area of the PNG image
Since:
FORMfields v3.0

scrambleScanLine

public array scrambleScanLine(array line)

Returns a scrambled scanline by randomly changing the color of random pixels.

Parameters:
line - an array of colors, representing a scanline
Returns:
a scrambled line of colors
Since:
FORMfields v3.0

FORMfields