Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain committed Oct 7, 2018
1 parent 7ec4f11 commit 99c369d
Show file tree
Hide file tree
Showing 36 changed files with 8,419 additions and 8,154 deletions.
93 changes: 47 additions & 46 deletions src/main/java/com/jhlabs/image/AbstractBufferedImageOp.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2005 Huxtable.com. All rights reserved.
*/
** Copyright 2005 Huxtable.com. All rights reserved.
*/

package com.jhlabs.image;

Expand All @@ -13,47 +13,48 @@
*/
public abstract class AbstractBufferedImageOp implements BufferedImageOp {

public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
if ( dstCM == null )
dstCM = src.getColorModel();
return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);
}

public Rectangle2D getBounds2D( BufferedImage src ) {
return new Rectangle(0, 0, src.getWidth(), src.getHeight());
}

public Point2D getPoint2D( Point2D srcPt, Point2D dstPt ) {
if ( dstPt == null )
dstPt = new Point2D.Double();
dstPt.setLocation( srcPt.getX(), srcPt.getY() );
return dstPt;
}

public RenderingHints getRenderingHints() {
return null;
}

/**
* A convenience method for getting ARGB pixels from an image. This tries to avoid the performance
* penalty of BufferedImage.getRGB unmanaging the image.
*/
public int[] getRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
int type = image.getType();
if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
return (int [])image.getRaster().getDataElements( x, y, width, height, pixels );
return image.getRGB( x, y, width, height, pixels, 0, width );
}

/**
* A convenience method for setting ARGB pixels in an image. This tries to avoid the performance
* penalty of BufferedImage.setRGB unmanaging the image.
*/
public void setRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
int type = image.getType();
if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
image.getRaster().setDataElements( x, y, width, height, pixels );
else
image.setRGB( x, y, width, height, pixels, 0, width );
}
}
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
if (dstCM == null) dstCM = src.getColorModel();
return new BufferedImage(
dstCM,
dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()),
dstCM.isAlphaPremultiplied(),
null);
}

public Rectangle2D getBounds2D(BufferedImage src) {
return new Rectangle(0, 0, src.getWidth(), src.getHeight());
}

public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
if (dstPt == null) dstPt = new Point2D.Double();
dstPt.setLocation(srcPt.getX(), srcPt.getY());
return dstPt;
}

public RenderingHints getRenderingHints() {
return null;
}

/**
* A convenience method for getting ARGB pixels from an image. This tries to avoid the performance
* penalty of BufferedImage.getRGB unmanaging the image.
*/
public int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB)
return (int[]) image.getRaster().getDataElements(x, y, width, height, pixels);
return image.getRGB(x, y, width, height, pixels, 0, width);
}

/**
* A convenience method for setting ARGB pixels in an image. This tries to avoid the performance
* penalty of BufferedImage.setRGB unmanaging the image.
*/
public void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB)
image.getRaster().setDataElements(x, y, width, height, pixels);
else image.setRGB(x, y, width, height, pixels, 0, width);
}
}
Loading

0 comments on commit 99c369d

Please sign in to comment.