function prepareImage(image, newWidth, newHeight) {
    var dtStart = new Date();

    console.log('image size: ' + image.width + 'x' + image.height + ' => ' + newWidth + 'x' + newHeight);
    var paletteMod = $('#cbPaletteMod').val();
    var forColumnRead = $('#cbForColumnRead').is(':checked');
    var bytePerPixel = Math.ceil(parseInt(paletteMod) / 8);
    console.log('paletteMod: ' + paletteMod + ' (' + bytePerPixel + 'bytes/pixel)');

    var imageWidth = newWidth;
    var imageHeight = newHeight;

    // create a canvas for the image
    var canvas = $('<canvas />')[0];
    canvas.width = imageWidth;
    canvas.height = imageHeight;
    var context = canvas.getContext('2d');
    // set smoothing for resize
    if (newWidth != image.width) {
        context.mozImageSmoothingEnabled = true;
        context.imageSmoothingQuality = "medium";
        context.webkitImageSmoothingEnabled = true;
        context.msImageSmoothingEnabled = true;
        context.imageSmoothingEnabled = true;
    }

    // load the image into the context
    context.drawImage(image, 0, 0, imageWidth, imageHeight);

    // get the pixels
    var origPixels = context.getImageData(0, 0, imageWidth, imageHeight).data; // Uint8ClampedArray

    //var isSingleArray = $('[type="radio"][name="cbArrayType"]:checked').val() == 'SINGLE';

    // do image convert
    var convertResult = imageConverter.convert(imageWidth, imageHeight, bytePerPixel, paletteMod, origPixels, forColumnRead);
    var moddedPixels = convertResult.moddedPixels;
    var newPixels = convertResult.newPixels;

    console.log('duration: ' + ((new Date()) - dtStart) + 'ms');
    console.log('moddedPixels size: ' + moddedPixels.byteLength + 'bytes')
    console.log('newPixels size: ' + newPixels.byteLength + 'bytes')
    return { moddedPixels: moddedPixels, newPixels: newPixels };
}
/**
 * Converts the image to the specified format, and returns the modified pixels in the new format along with them in 24bit format
 */
Converts the image to the specified format, and returns the modified pixels in the new format along with them in 24bit format
Converts the image to the specified format and returns the modified pixels in the new format along with them in 24bit format
function prepareImage(image, newWidth, newHeight) {
    var dtStart = new Date();
    console.log('image size: ' + image.width + 'x' + image.height + ' => ' + newWidth + 'x' + newHeight);
    var paletteMod = $('#cbPaletteMod').val();
    var forColumnRead = $('#cbForColumnRead').is(':checked');
    var bytePerPixel = Math.ceil(parseInt(paletteMod) / 8);
    console.log('paletteMod: ' + paletteMod + ' (' + bytePerPixel + 'bytes/pixel)');
    var imageWidth = newWidth;
    var imageHeight = newHeight;
    var canvas = $('<canvas />')[0];
    canvas.width = imageWidth;
    canvas.height = imageHeight;
    var context = canvas.getContext('2d');
    if (newWidth != image.width) {
        context.mozImageSmoothingEnabled = true;
        context.imageSmoothingQuality = "medium";
        context.webkitImageSmoothingEnabled = true;
        context.msImageSmoothingEnabled = true;
        context.imageSmoothingEnabled = true;
    }
    context.drawImage(image, 0, 0, imageWidth, imageHeight);
    var origPixels = context.getImageData(0, 0, imageWidth, imageHeight).data; 
    var convertResult = imageConverter.convert(imageWidth, imageHeight, bytePerPixel, paletteMod, origPixels, forColumnRead);
    var moddedPixels = convertResult.moddedPixels;
    var newPixels = convertResult.newPixels;
    console.log('duration: ' + ((new Date()) - dtStart) + 'ms');
    console.log('moddedPixels size: ' + moddedPixels.byteLength + 'bytes')
    console.log('newPixels size: ' + newPixels.byteLength + 'bytes')
    return { moddedPixels: moddedPixels, newPixels: newPixels };
}
function prepareImage ( image , newWidth , newHeight ) { var dtStart = new Date ( ) ; console . log ( 'image size: ' + image . width + 'x' + image . height + ' => ' + newWidth + 'x' + newHeight ) ; var paletteMod = $ ( '#cbPaletteMod' ) . val ( ) ; var forColumnRead = $ ( '#cbForColumnRead' ) . is ( ':checked' ) ; var bytePerPixel = Math . ceil ( parseInt ( paletteMod ) / 8 ) ; console . log ( 'paletteMod: ' + paletteMod + ' (' + bytePerPixel + 'bytes/pixel)' ) ; var imageWidth = newWidth ; var imageHeight = newHeight ; var canvas = $ ( '<canvas />' ) [ 0 ] ; canvas . width = imageWidth ; canvas . height = imageHeight ; var context = canvas . getContext ( '2d' ) ; if ( newWidth != image . width ) { context . mozImageSmoothingEnabled = true ; context . imageSmoothingQuality = "medium" ; context . webkitImageSmoothingEnabled = true ; context . msImageSmoothingEnabled = true ; context . imageSmoothingEnabled = true ; } context . drawImage ( image , 0 , 0 , imageWidth , imageHeight ) ; var origPixels = context . getImageData ( 0 , 0 , imageWidth , imageHeight ) . data ; var convertResult = imageConverter . convert ( imageWidth , imageHeight , bytePerPixel , paletteMod , origPixels , forColumnRead ) ; var moddedPixels = convertResult . moddedPixels ; var newPixels = convertResult . newPixels ; console . log ( 'duration: ' + ( ( new Date ( ) ) - dtStart ) + 'ms' ) ; console . log ( 'moddedPixels size: ' + moddedPixels . byteLength + 'bytes' ) console . log ( 'newPixels size: ' + newPixels . byteLength + 'bytes' ) return { moddedPixels : moddedPixels , newPixels : newPixels } ; }
Converts the image to the specified format, and returns the modified pixels in the new format along with them in 24bit format
Converts the image to the specified format and returns the modified pixels in the new format along with them in 24bit format
// create a canvas for the image // set smoothing for resize // load the image into the context // get the pixels // Uint8ClampedArray //var isSingleArray = $('[type="radio"][name="cbArrayType"]:checked').val() == 'SINGLE'; // do image convert