|
|
|
@ -91,6 +91,11 @@ function PaintWeb (win, doc) {
|
|
|
|
|
*/
|
|
|
|
|
this.layer = {id: null, canvas: null, context: null};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 원본 이미지
|
|
|
|
|
*/
|
|
|
|
|
this.orginl = {canvas: null, context: null};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The instance of the active tool object.
|
|
|
|
|
*
|
|
|
|
@ -168,6 +173,12 @@ function PaintWeb (win, doc) {
|
|
|
|
|
*/
|
|
|
|
|
this.win = win;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 밝기조절 슬라이더 값
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
this.brightnessSliderValue = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Holds image information: width, height, zoom and more.
|
|
|
|
|
*
|
|
|
|
@ -742,6 +753,8 @@ function PaintWeb (win, doc) {
|
|
|
|
|
this.commandRegister('clipboardPaste', this.clipboardPaste) &&
|
|
|
|
|
this.commandRegister('imageSave', this.imageSave) &&
|
|
|
|
|
this.commandRegister('imageRotate', this.imageRotate) &&
|
|
|
|
|
this.commandRegister('imageBright', this.imageBright) &&
|
|
|
|
|
this.commandRegister('imageDark', this.imageDark) &&
|
|
|
|
|
this.commandRegister('imageClear', this.imageClear) &&
|
|
|
|
|
this.commandRegister('swapFillStroke', this.swapFillStroke) &&
|
|
|
|
|
this.commandRegister('imageZoomIn', this.imageZoomIn) &&
|
|
|
|
@ -877,8 +890,10 @@ function PaintWeb (win, doc) {
|
|
|
|
|
resInfo = doc.getElementById(res.elemId),
|
|
|
|
|
layerCanvas = doc.createElement('canvas'),
|
|
|
|
|
bufferCanvas = doc.createElement('canvas'),
|
|
|
|
|
orginlCanvas = doc.createElement('canvas'),
|
|
|
|
|
layerContext = layerCanvas.getContext('2d'),
|
|
|
|
|
bufferContext = bufferCanvas.getContext('2d'),
|
|
|
|
|
orginlContext = orginlCanvas.getContext('2d'),
|
|
|
|
|
width = cfg.imageWidth,
|
|
|
|
|
height = cfg.imageHeight,
|
|
|
|
|
imageLoad = cfg.imageLoad;
|
|
|
|
@ -914,16 +929,20 @@ function PaintWeb (win, doc) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.elem = resInfo;
|
|
|
|
|
this.image.width = layerCanvas.width = bufferCanvas.width = width;
|
|
|
|
|
this.image.height = layerCanvas.height = bufferCanvas.height = height;
|
|
|
|
|
this.image.width = layerCanvas.width = bufferCanvas.width = orginlCanvas.width = width;
|
|
|
|
|
this.image.height = layerCanvas.height = bufferCanvas.height = orginlCanvas.height = height;
|
|
|
|
|
|
|
|
|
|
this.layer.canvas = layerCanvas;
|
|
|
|
|
this.layer.context = layerContext;
|
|
|
|
|
this.buffer.canvas = bufferCanvas;
|
|
|
|
|
this.buffer.context = bufferContext;
|
|
|
|
|
this.orginl.canvas = orginlCanvas;
|
|
|
|
|
this.orginl.context = orginlContext;
|
|
|
|
|
|
|
|
|
|
if (imageLoad) {
|
|
|
|
|
layerContext.drawImage(imageLoad, 0, 0);
|
|
|
|
|
orginlContext.drawImage(imageLoad,0,0);
|
|
|
|
|
orginlCanvas.style.display = 'none';
|
|
|
|
|
} else {
|
|
|
|
|
// Set the configured background color.
|
|
|
|
|
var fillStyle = layerContext.fillStyle;
|
|
|
|
@ -2804,10 +2823,86 @@ function PaintWeb (win, doc) {
|
|
|
|
|
var zoom = _self.image.zoom;
|
|
|
|
|
_self.image.zoom=1;
|
|
|
|
|
_self.imageZoomTo(zoom);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 밝기 조절(이미지 밝게)
|
|
|
|
|
*/
|
|
|
|
|
this.imageBright = function (type) {
|
|
|
|
|
_self.brightnessSliderChange(20);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 밝기 조절(이미지 어둡게)
|
|
|
|
|
*/
|
|
|
|
|
this.imageDark = function (type) {
|
|
|
|
|
_self.brightnessSliderChange(-20);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.brightnessSliderChange = function(step){
|
|
|
|
|
|
|
|
|
|
_self.brightnessSliderValue += step;
|
|
|
|
|
if(_self.brightnessSliderValue < -255){
|
|
|
|
|
_self.brightnessSliderValue = -255;
|
|
|
|
|
} else if(_self.brightnessSliderValue > 255){
|
|
|
|
|
_self.brightnessSliderValue = 255;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// imageData를 가져온다.
|
|
|
|
|
let orginlCanvasWidth = _self.orginl.canvas.width;
|
|
|
|
|
let orginlCanvasHeight = _self.orginl.canvas.height;
|
|
|
|
|
let orginlCtx = _self.orginl.context;
|
|
|
|
|
|
|
|
|
|
let pixels = orginlCtx.getImageData(0,0, orginlCanvasWidth, orginlCanvasHeight);
|
|
|
|
|
|
|
|
|
|
// image processing
|
|
|
|
|
let filteredData = _self.brightnessCalc(pixels, _self.brightnessSliderValue);
|
|
|
|
|
|
|
|
|
|
// Canvas에 다시 그린다.
|
|
|
|
|
let jobCtx = _self.layer.context;
|
|
|
|
|
jobCtx.putImageData(filteredData, 0 , 0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.brightnessCalc = function(pixels, sliderValue) {
|
|
|
|
|
let imgSource = pixels.data;
|
|
|
|
|
|
|
|
|
|
for(let i =0; i< imgSource.length; i+=4){
|
|
|
|
|
let tempR = imgSource[i];
|
|
|
|
|
let tempG = imgSource[i+1];
|
|
|
|
|
let tempB = imgSource[i+2];
|
|
|
|
|
|
|
|
|
|
tempR += sliderValue;
|
|
|
|
|
tempG += sliderValue;
|
|
|
|
|
tempB += sliderValue;
|
|
|
|
|
|
|
|
|
|
if(tempR < 0){
|
|
|
|
|
tempR = 0;
|
|
|
|
|
} else if(tempR > 255){
|
|
|
|
|
tempR = 255;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tempG < 0){
|
|
|
|
|
tempG = 0;
|
|
|
|
|
} else if(tempG > 255){
|
|
|
|
|
tempG = 255;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tempB < 0){
|
|
|
|
|
tempB = 0;
|
|
|
|
|
} else if(tempB > 255){
|
|
|
|
|
tempB = 255;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
imgSource[i] = tempR;
|
|
|
|
|
imgSource[i+1] = tempG;
|
|
|
|
|
imgSource[i+2] = tempB;
|
|
|
|
|
}
|
|
|
|
|
return pixels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The <code>imageSaveResult</code> application event handler. This method
|
|
|
|
|
* PaintWeb-related stuff: for example, the {@link PaintWeb.image.modified}
|
|
|
|
|