Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

71
LINES

< > BotCompany Repo | #1018735 // AbstractBufferedImageOp

JavaX fragment (include)

1  
import java.awt.geom.*;
2  
3  
abstract sclass AbstractBufferedImageOp implements BufferedImageOp, Cloneable {
4  
    public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
5  
        if ( dstCM == null )
6  
            dstCM = src.getColorModel();
7  
        return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);
8  
    }
9  
    
10  
    public Rectangle2D getBounds2D( BufferedImage src ) {
11  
        return new Rectangle(0, 0, src.getWidth(), src.getHeight());
12  
    }
13  
    
14  
    public Point2D getPoint2D( Point2D srcPt, Point2D dstPt ) {
15  
        if ( dstPt == null )
16  
            dstPt = new Point2D.Double();
17  
        dstPt.setLocation( srcPt.getX(), srcPt.getY() );
18  
        return dstPt;
19  
    }
20  
21  
    public RenderingHints getRenderingHints() {
22  
        return null;
23  
    }
24  
25  
	/**
26  
	 * A convenience method for getting ARGB pixels from an image. This tries to avoid the performance
27  
	 * penalty of BufferedImage.getRGB unmanaging the image.
28  
     * @param image   a BufferedImage object
29  
     * @param x       the left edge of the pixel block
30  
     * @param y       the right edge of the pixel block
31  
     * @param width   the width of the pixel arry
32  
     * @param height  the height of the pixel arry
33  
     * @param pixels  the array to hold the returned pixels. May be null.
34  
     * @return the pixels
35  
     * @see #setRGB
36  
     */
37  
	public int[] getRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
38  
		int type = image.getType();
39  
		if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
40  
			return (int [])image.getRaster().getDataElements( x, y, width, height, pixels );
41  
		return image.getRGB( x, y, width, height, pixels, 0, width );
42  
    }
43  
44  
	/**
45  
	 * A convenience method for setting ARGB pixels in an image. This tries to avoid the performance
46  
	 * penalty of BufferedImage.setRGB unmanaging the image.
47  
     * @param image   a BufferedImage object
48  
     * @param x       the left edge of the pixel block
49  
     * @param y       the right edge of the pixel block
50  
     * @param width   the width of the pixel arry
51  
     * @param height  the height of the pixel arry
52  
     * @param pixels  the array of pixels to set
53  
     * @see #getRGB
54  
	 */
55  
	public void setRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
56  
		int type = image.getType();
57  
		if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
58  
			image.getRaster().setDataElements( x, y, width, height, pixels );
59  
		else
60  
			image.setRGB( x, y, width, height, pixels, 0, width );
61  
    }
62  
63  
	public Object clone() {
64  
		try {
65  
			return super.clone();
66  
		}
67  
		catch ( CloneNotSupportedException e ) {
68  
			return null;
69  
		}
70  
	}
71  
}

Author comment

from https://github.com/ajmas/JH-Labs-Java-Image-Filters/blob/master/src/com/jhlabs/image/AbstractBufferedImageOp.java

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018735
Snippet name: AbstractBufferedImageOp
Eternal ID of this version: #1018735/2
Text MD5: 2f7b2b7d016ea0981fe727fe3422c15b
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-12 12:13:15
Source code size: 2813 bytes / 71 lines
Pitched / IR pitched: No / No
Views / Downloads: 308 / 864
Version history: 1 change(s)
Referenced in: [show references]