jsjpeg.js
/**
 * Scale the component from its native size to the image's size, placing the output
 * into the component's outputBuff
 * 
 * @param {*} component 
 */
Scale the component from its native size to the image's size, placing the output
into the component's outputBuff

@param {*} component
Scale the component from its native size to the image ' s size placing the output into the component ' s outputBuff @param { * } component
function scaleComponent(component) {
    let hScale = img.frame.outputX / component.hSize;  
    let vScale = img.frame.outputY / component.vSize;  
    if (hScale === 1 && vScale === 1) {     
        component.outputBuff.set(component.imgBuff, 0);
        return;
    }
    for (let sy = 0, dy = 0; sy < component.vSize; sy++, dy+=vScale) {
        let srcLineStart = sy * component.hSize;
        for (let sx = 0, dx = 0; sx < component.hSize; sx++, dx+=hScale) {
            let val = component.imgBuff[srcLineStart + sx];
            for (let y = 0; y < vScale; y++) {
                for (let x = 0; x < hScale; x++) {
                    let destY = dy + y;
                    let destX = dx + x;
                    component.outputBuff[(destY * img.frame.outputX) + destX] = val;
                }
            }
        }
    }
}
function scaleComponent ( component ) { let hScale = img . frame . outputX / component . hSize ; let vScale = img . frame . outputY / component . vSize ; if ( hScale === 1 && vScale === 1 ) { component . outputBuff . set ( component . imgBuff , 0 ) ; return ; } for ( let sy = 0 , dy = 0 ; sy < component . vSize ; sy ++ , dy += vScale ) { let srcLineStart = sy * component . hSize ; for ( let sx = 0 , dx = 0 ; sx < component . hSize ; sx ++ , dx += hScale ) { let val = component . imgBuff [ srcLineStart + sx ] ; for ( let y = 0 ; y < vScale ; y ++ ) { for ( let x = 0 ; x < hScale ; x ++ ) { let destY = dy + y ; let destX = dx + x ; component . outputBuff [ ( destY * img . frame . outputX ) + destX ] = val ; } } } } }
Scale the component from its native size to the image's size, placing the output
 into the component's outputBuff
Scale the component from its native size to the image ' s size placing the output into the component ' s outputBuff
// Factor to scale component up to output side // Factor to scale component up to output side // Optimization