• R/O
  • SSH
  • HTTPS

kirikirij: Commit


Commit MetaInfo

Revision181 (tree)
Time2012-07-16 22:06:29
Authorjin1016

Log Message

copyRect で一時領域へコピーするかどうかの判定をより厳格に

Change Summary

Incremental Difference

--- base/trunk/src/src/jp/kirikiri/tvp2env/NativeImageBuffer.java (revision 180)
+++ base/trunk/src/src/jp/kirikiri/tvp2env/NativeImageBuffer.java (revision 181)
@@ -258,29 +258,32 @@
258258 return ret;
259259 }
260260 public final boolean copyRect(int x, int y, NativeImageBuffer src, Rect refrect, int plane) {
261+ Graphics2D g = (Graphics2D)mImage.getGraphics();
262+ if( (BaseBitmap.BB_COPY_MAIN|BaseBitmap.BB_COPY_MASK) == plane ) {
263+ g.setComposite( AlphaComposite.Src );
264+ } else if( BaseBitmap.BB_COPY_MAIN == plane ) {
265+ g.setComposite(new CustomOperationComposite( CustomOperationComposite.copyMain, 255, false ));
266+ } else if( BaseBitmap.BB_COPY_MASK == plane ) {
267+ g.setComposite(new CustomOperationComposite( CustomOperationComposite.copyMask, 255, false ));
268+ }
269+
270+ int h = refrect.height();
271+ int w = refrect.width();
261272 BufferedImage tmp;
262- if( this == src ) {
273+ if( this == src && y >= refrect.top && (y - refrect.top) < h && x >= refrect.left && (x-refrect.left) < w ) {
274+ //int height = y - refrect.top;
263275 // コピー元とコピー先が同じ場合は、一端テンポラリへコピーする
276+ // テンポラリへ入れなくても、下から順にコピーしていけば大丈夫なようだが速度が気になる
264277 int type = src.mImage.getType();
265- int w = refrect.width();
266- int h = refrect.height();
267278 tmp = new BufferedImage( w, h, type );
268- Graphics2D g = (Graphics2D)tmp.getGraphics();
269- g.setComposite( AlphaComposite.Src );
270- g.drawImage( src.mImage, 0, 0, w, h, refrect.left, refrect.top, refrect.right, refrect.bottom, null );
271- g.dispose();
279+ Graphics2D tg = (Graphics2D)tmp.getGraphics();
280+ tg.setComposite( AlphaComposite.Src );
281+ tg.drawImage( src.mImage, 0, 0, w, h, refrect.left, refrect.top, refrect.right, refrect.bottom, null );
282+ tg.dispose();
272283 refrect = new Rect(0,0,w,h);
273284 } else {
274285 tmp = src.mImage;
275286 }
276- Graphics2D g = (Graphics2D)mImage.getGraphics();
277- if( (BaseBitmap.BB_COPY_MAIN|BaseBitmap.BB_COPY_MASK) == plane ) {
278- g.setComposite( AlphaComposite.Src );
279- } else if( BaseBitmap.BB_COPY_MAIN == plane ) {
280- g.setComposite(new CustomOperationComposite( CustomOperationComposite.copyMain, 255, false ));
281- } else if( BaseBitmap.BB_COPY_MASK == plane ) {
282- g.setComposite(new CustomOperationComposite( CustomOperationComposite.copyMask, 255, false ));
283- }
284287 boolean ret = g.drawImage( tmp, x, y, x+refrect.width(), y+refrect.height(),
285288 refrect.left, refrect.top, refrect.right, refrect.bottom, null );
286289 g.dispose();
Show on old repository browser