페인트웹 수정(이미지 자르기,회전 처리 후 밝기 조정 오류 수정)

main
이범준 7 months ago
parent 73cf15a621
commit 7807025b15

@ -1523,11 +1523,13 @@ function PaintWeb (win, doc) {
* not. * not.
*/ */
this.imageCrop = function (cropX, cropY, cropWidth, cropHeight) { this.imageCrop = function (cropX, cropY, cropWidth, cropHeight) {
var bufferCanvas = this.buffer.canvas, var orginlCanvas = this.orginl.canvas;
bufferContext = this.buffer.context, var orginlContext = this.orginl.context;
image = this.image, var bufferCanvas = this.buffer.canvas;
layerCanvas = this.layer.canvas, var bufferContext = this.buffer.context;
layerContext = this.layer.context; var layerCanvas = this.layer.canvas;
var layerContext = this.layer.context;
var image = this.image;
cropX = parseInt(cropX); cropX = parseInt(cropX);
cropY = parseInt(cropY); cropY = parseInt(cropY);
@ -1594,9 +1596,12 @@ function PaintWeb (win, doc) {
layerCanvas.width = cropWidth; layerCanvas.width = cropWidth;
layerCanvas.height = cropHeight; layerCanvas.height = cropHeight;
orginlCanvas.width = cropWidth;
orginlCanvas.height = cropHeight;
if (layerData && layerContext.putImageData) { if (layerData && layerContext.putImageData) {
layerContext.putImageData(layerData, 0, 0); layerContext.putImageData(layerData, 0, 0);
orginlContext.putImageData(layerData, 0, 0);
} }
this.stateRestore(layerContext, layerState); this.stateRestore(layerContext, layerState);
@ -1849,12 +1854,12 @@ function PaintWeb (win, doc) {
* *
* @private * @private
*/ */
this.historyReset = function () { this.historyReset = function () {
this.history.pos = 0; this.history.pos = 0;
this.history.states = []; this.history.states = [];
this.brightnessSliderValue = 0;
this.events.dispatch(new appEvent.historyUpdate(0, 0, 0)); this.events.dispatch(new appEvent.historyUpdate(0, 0, 0));
}; };
/** /**
* Perform horizontal/vertical line snapping. This method updates the mouse * Perform horizontal/vertical line snapping. This method updates the mouse
@ -2491,39 +2496,44 @@ function PaintWeb (win, doc) {
}; };
this.imageRotate = function(clockwise){ this.imageRotate = function(clockwise){
var layerCanvas = _self.layer.canvas, var orginlCanvas = _self.orginl.canvas;
layerCtx = _self.layer.context, var orginlCtx = _self.orginl.context;
bufferCanvas = _self.buffer.canvas,
bufferCtx = _self.buffer.context,
img = _self.image;
var bufferStyle = _self.buffer.canvas.style; var layerCanvas = _self.layer.canvas;
var layerCtx = _self.layer.context;
var layerStyle = layerCanvas.style; var layerStyle = layerCanvas.style;
var srcCanvas = doc.createElement('canvas'); var bufferCanvas = _self.buffer.canvas;
var srcCtx=srcCanvas.getContext("2d"); var bufferStyle = _self.buffer.canvas.style;
var bufferCtx = _self.buffer.context;
var img = _self.image;
var newCanvas = doc.createElement('canvas');
var newCtx = newCanvas.getContext("2d");
srcCanvas.height = layerCanvas.width; newCanvas.height = layerCanvas.width;
srcCanvas.width = layerCanvas.height; newCanvas.width = layerCanvas.height;
srcCtx.translate(layerCanvas.height/2,layerCanvas.width/2); newCtx.translate(layerCanvas.height/2,layerCanvas.width/2);
if(clockwise){ if(clockwise){
srcCtx.rotate(90*Math.PI/180); newCtx.rotate(90*Math.PI/180);
} else { } else {
srcCtx.rotate(-90*Math.PI/180); newCtx.rotate(-90*Math.PI/180);
} }
srcCtx.drawImage(layerCanvas,-layerCanvas.width/2,-layerCanvas.height/2); newCtx.drawImage(layerCanvas,-layerCanvas.width/2,-layerCanvas.height/2);
var lineWidth = bufferCtx.lineWidth; var lineWidth = bufferCtx.lineWidth;
var strokeStyle = bufferCtx.strokeStyle; var strokeStyle = bufferCtx.strokeStyle;
var fillStyle = bufferCtx.fillStyle; var fillStyle = bufferCtx.fillStyle;
layerCanvas.width = bufferCanvas.width = srcCanvas.width; orginlCanvas.width = layerCanvas.width = bufferCanvas.width = newCanvas.width;
layerCanvas.height = bufferCanvas.height = srcCanvas.height; orginlCanvas.height = layerCanvas.height = bufferCanvas.height = newCanvas.height;
bufferCtx.lineWidth = layerCtx.lineWidth = lineWidth; orginlCtx.lineWidth = bufferCtx.lineWidth = layerCtx.lineWidth = lineWidth;
bufferCtx.strokeStyle = layerCtx.strokeStyle = strokeStyle; orginlCtx.strokeStyle = bufferCtx.strokeStyle = layerCtx.strokeStyle = strokeStyle;
bufferCtx.fillStyle = layerCtx.fillStyle = fillStyle; orginlCtx.fillStyle = bufferCtx.fillStyle = layerCtx.fillStyle = fillStyle;
layerCtx.drawImage(srcCanvas, 0, 0); layerCtx.drawImage(newCanvas, 0, 0);
orginlCtx.drawImage(newCanvas, 0, 0);
img.width = layerCanvas.width; img.width = layerCanvas.width;
img.height = layerCanvas.height; img.height = layerCanvas.height;
@ -2535,8 +2545,7 @@ function PaintWeb (win, doc) {
pw.image.modified = true; pw.image.modified = true;
pw.history.pos = 0; pw.historyReset();
pw.history.states = [];
return true; return true;
} }

@ -1408,8 +1408,7 @@ pwlib.tools.selection = function (app) {
isNumberPlate = false; isNumberPlate = false;
app.history.pos = 0; app.historyReset();
app.history.states = [];
return true; return true;
}; };
@ -1445,8 +1444,7 @@ pwlib.tools.selection = function (app) {
isNumberPlate = true; isNumberPlate = true;
app.history.pos = 0; app.historyReset();
app.history.states = [];
return true; return true;
}; };

Loading…
Cancel
Save