当前位置: 首页>>代码示例>>Java>>正文


Java BufferedImage.getWidth方法代码示例

本文整理汇总了Java中java.awt.image.BufferedImage.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.getWidth方法的具体用法?Java BufferedImage.getWidth怎么用?Java BufferedImage.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.BufferedImage的用法示例。


在下文中一共展示了BufferedImage.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
@Override
public final BufferedImage apply(BufferedImage img) {
	
	float[][] matrix = getMatrix();
	float[] data = getKernelData(matrix);
	if(normalize)
		normalize(data); 
	scale(data);
	if(isZero(data))
		return new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
	
	Kernel k = new Kernel(matrix[0].length, matrix.length, data);
	ConvolveOp op = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null);
	
	BufferedImage img2 = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
	img2.getGraphics().drawImage(img, 0, 0, null);
	
	return op.filter(img2, null);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:20,代码来源:ConvolutionFilter.java

示例2: loadCropResult

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
 * Load the segmented result of the crop image to a visualisation panel.
 */
private void loadCropResult(BufferedImage cropResult) {
    // remove the old image if it exists
    if (dPCropResult != null) {
        this.remove(dPCropResult);
        jPCropResult.remove(dPCropResult);
    }

    // load the viewer of the result
    dPCropResult = new ResultPanel(cropResult, new Dimension(cropResult.getWidth(), cropResult.getHeight()), cropWindowConfig.getObjectColor());
    dPCropResult.updateResultImg();
    dPCropResult.setBackground(new java.awt.Color(255, 255, 255));

    jPCropResult.add(dPCropResult);

    this.validate();
    this.repaint();

}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:22,代码来源:CropWindow.java

示例3: apply

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
@Override
protected BufferedImage apply(BufferedImage img) {

	float flength = 1 + (img.getWidth()-1) * threshold;
	int length = Math.round(flength);

	for (int y = 0, x = 0; y < img.getHeight(); y++) {
		for(x = 0; x < img.getWidth() && ((img.getRGB(x, y) & 0xFF000000) == 0); x++);

		int firstEnd = Math.round(flength*(x/length +1)) -1;

		line(img, x, Math.min(img.getWidth()-1, firstEnd), y);
		x = firstEnd+1;

		for(float fx = x; x < img.getWidth()-length && ((img.getRGB(x + length, y) & 0xFF000000) != 0); fx += flength, x = Math.round(fx))
			line(img, x, Math.round(fx + flength)-1, y);

		int end = x;
		for(; end < img.getWidth() - 1 && ((img.getRGB(end, y) & 0xFF000000) != 0); end++);
		line(img, x, end, y);
	}
	return img;
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:24,代码来源:LinePixelSort.java

示例4: resizeImage

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
private static BufferedImage resizeImage(BufferedImage sample, double sampleMinLat, double sampleMaxLat, double tileMinLat, double tileMaxLat) {
	BufferedImage img = new BufferedImage(TILE_SIZE, TILE_SIZE, BufferedImage.TYPE_3BYTE_BGR);
	double tileScale = TILE_SIZE / (tileMinLat - tileMaxLat);
	
	// s for source; d for destination; all measurements in pixels
	int sx1 = 0;
	int sy1 = 0;
	int sx2 = sample.getWidth();
	int sy2 = sample.getHeight();
	
	int dx1 = 0;
	int dy1 = (int) ((sampleMaxLat - tileMaxLat) * tileScale);
	int dx2 = TILE_SIZE;
	int dy2 = (int) ((sampleMinLat - tileMaxLat) * tileScale);
	
	img.createGraphics().drawImage(sample, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
	
	return img;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:20,代码来源:GeoMapAppToWorldWindTiler.java

示例5: uploadTextureImageSubImpl

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
private static void uploadTextureImageSubImpl(BufferedImage p_110993_0_, int p_110993_1_, int p_110993_2_, boolean p_110993_3_, boolean p_110993_4_)
{
    int i = p_110993_0_.getWidth();
    int j = p_110993_0_.getHeight();
    int k = 4194304 / i;
    int[] aint = new int[k * i];
    setTextureBlurred(p_110993_3_);
    setTextureClamped(p_110993_4_);

    for (int l = 0; l < i * j; l += i * k)
    {
        int i1 = l / i;
        int j1 = Math.min(k, j - i1);
        int k1 = i * j1;
        p_110993_0_.getRGB(0, i1, i, j1, aint, 0, i);
        copyToBuffer(aint, k1);
        GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, p_110993_1_, p_110993_2_ + i1, i, j1, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)dataBuffer);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:TextureUtil.java

示例6: maskSelection

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
 * Creates a new image in which every pixel not within the given shape has been changed to fully transparent.
 *
 * @param image The image to mask
 * @param mask  The shape bounding the subimage to keep
 * @return A BufferedImage in which every pixel not within the selection has been made fully transparent
 */
private BufferedImage maskSelection(BufferedImage image, Shape mask) {
    BufferedImage subimage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);

    int clearPixel = new Color(0, 0, 0, 0).getRGB();

    for (int y = 0; y < image.getRaster().getHeight(); y++) {
        for (int x = 0; x < image.getRaster().getWidth(); x++) {
            if (x > image.getWidth() || y > image.getHeight()) continue;

            if (mask.contains(x, y)) {
                subimage.setRGB(x, y, image.getRGB(x, y));
            } else {
                subimage.setRGB(x, y, clearPixel);
            }
        }
    }

    return subimage;
}
 
开发者ID:defano,项目名称:jmonet,代码行数:27,代码来源:AbstractSelectionTool.java

示例7: createSystemTrayIconImage

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
private Image createSystemTrayIconImage() {
    final BufferedImage trayImage = new BufferedImage(
            imageSize,
            imageSize,
            BufferedImage.TYPE_INT_ARGB);

    final Graphics2D imageGraphics = (Graphics2D) trayImage.getGraphics();

    imageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

    imageGraphics.setColor(new Color(255, 255, 255, 0));
    imageGraphics.fillRect(0, 0, trayImage.getWidth(),
            trayImage.getHeight());

    imageGraphics.setColor(Color.green);

    int imageWidth = trayImage.getWidth() - 2 * imageInset;
    int imageHeight = trayImage.getHeight() - 2 * imageInset;

    imageGraphics.fillOval(imageInset, imageInset, imageWidth, imageHeight);
    imageGraphics.setColor(Color.darkGray);
    imageGraphics.drawOval(imageInset, imageInset, imageWidth, imageHeight);

    return trayImage;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:UpdatePopupMenu.java

示例8: getPixelsOutline

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
Rectangle getPixelsOutline(BufferedImage img) {
    int x1 = 0;
    while (x1 < img.getWidth() && isLineEmpty(img, x1, false)) {
        x1++;
    }
    int x2 = img.getWidth() - 1;
    while (x2 >= 0 && isLineEmpty(img, x2, false)) {
        x2--;
    }
    int y1 = 0;
    while (y1 < img.getHeight() && isLineEmpty(img, y1, true)) {
        y1++;
    }
    int y2 = img.getHeight() - 1;
    while (y2 >= 0 && isLineEmpty(img, y2, true)) {
        y2--;
    }

    return new Rectangle(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:bug8016833.java

示例9: countColor

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
 * Conta a quantidade de pixels com a cor {@code rgb} passada por parâmetro
 *
 * @param image imagem
 * @param rgb cor rgb
 * @return quantidade de pixels encontrados da cor {@code rgb}
 */
public static int countColor(BufferedImage image, int rgb) {
    int count = 0;
    for (int x = 0; x < image.getWidth(); x++) {
        for (int y = 0; y < image.getHeight(); y++) {
            if (image.getRGB(x, y) == rgb) {
                count++;
            }
        }
    }
    return count;
}
 
开发者ID:limagiran,项目名称:campominadobot,代码行数:19,代码来源:Utils.java

示例10: main

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {

        String fileName = "nomarkers.jpg";
        String sep = System.getProperty("file.separator");
        String dir = System.getProperty("test.src", ".");
        String filePath = dir+sep+fileName;
        System.out.println("Test file: " + filePath);
        File imageFile = new File(filePath);

        BufferedImage bufferedImage = ImageIO.read(imageFile);
        int imageWidth = bufferedImage.getWidth();
        int imageHeight = bufferedImage.getHeight();

        for (int i = 0; i < imageWidth; i++) {
            for(int j = 0; j < imageHeight; j++) {
                /*
                * Since image is white we check individual pixel values from
                * BufferedImage to verify if ImageIO.read() is done with proper
                * color space or not.
                */
                if (bufferedImage.getRGB(i, j) != Color.white.getRGB()) {
                    // color space is not proper
                    throw new RuntimeException("ColorSpace is not determined "
                            + "properly by ImageIO");
               }
            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:JpegImageColorSpaceTest.java

示例11: convertType

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
BufferedImage convertType(BufferedImage src, int targetType) {
	if (src.getType() == targetType) {
		return src;
	}
	BufferedImage tgt = new BufferedImage(src.getWidth(), src.getHeight(), targetType);
	Graphics2D g = tgt.createGraphics();
	g.drawRenderedImage(src, null);
	g.dispose();
	return tgt;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:11,代码来源:EnlargePlotDistGraph.java

示例12: getImagePixel

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public static Color getImagePixel(InputStream file) {
    int R = 0;
    int G = 0;
    int B = 0;
    List<String> list = new ArrayList<String>();
    BufferedImage bi = null;
    try {
        bi = ImageIO.read(file);
    } catch (Exception e) {
        e.printStackTrace();
    }
    int width = bi.getWidth();
    int height = bi.getHeight();
    int sum = width * height;
    int minx = bi.getMinX();
    int miny = bi.getMinY();
    for (int i = minx; i < width; i++) {
        for (int j = miny; j < height; j++) {
            int pixel = bi.getRGB(i, j);
            R = (pixel & 0xff0000) >> 16;
            G = (pixel & 0xff00) >> 8;
            B = (pixel & 0xff);
            list.add(R + "-" + G + "-" + B);
        }
    }
    return getMaxCount(list);
}
 
开发者ID:IzzelAliz,项目名称:LCL,代码行数:28,代码来源:GetMainColor.java

示例13: LoadTexture

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
private static TextureResource LoadTexture(String fileName)
{
	try
	{
		BufferedImage image = ImageIO.read(new File("./res/textures/" + fileName));
		int[] pixels = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth());

		ByteBuffer buffer = Util.CreateByteBuffer(image.getHeight() * image.getWidth() * 4);
		boolean hasAlpha = image.getColorModel().hasAlpha();

		for(int y = 0; y < image.getHeight(); y++)
		{
			for(int x = 0; x < image.getWidth(); x++)
			{
				int pixel = pixels[y * image.getWidth() + x];

				buffer.put((byte)((pixel >> 16) & 0xFF));
				buffer.put((byte)((pixel >> 8) & 0xFF));
				buffer.put((byte)((pixel) & 0xFF));
				if(hasAlpha)
					buffer.put((byte)((pixel >> 24) & 0xFF));
				else
					buffer.put((byte)(0xFF));
			}
		}

		buffer.flip();

		TextureResource resource = new TextureResource();
		glBindTexture(GL_TEXTURE_2D, resource.GetId());

		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

		return resource;
	}
	catch(Exception e)
	{
		e.printStackTrace();
		System.exit(1);
	}
	
	return null;
}
 
开发者ID:RagnarrIvarssen,项目名称:Assimp-Tutorial-LWJGL-3,代码行数:50,代码来源:Texture.java

示例14: MapPanel

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public MapPanel(JSpinner sx, JSpinner sy, JComboBox ci) {
	this.sx = sx;
	this.sy = sy;
	this.ci = ci;
	
	addMouseListener(this);
	
	ci.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			repaint();
		}
		
	});
	
	try {
		bg = ImageIO.read(new File(Settings.BASE_PATH + File.separatorChar + "gfx" + File.separatorChar + "MAP.bmp"));
		iconSheet = ImageIO.read(new File(Settings.BASE_PATH + File.separatorChar + "gfx" + File.separatorChar + "PK2STUFF.bmp"));
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	for (int i = 0; i < 22; i++) {
		iconList.add(iconSheet.getSubimage((i * 28) + 1, iconSheet.getHeight() - 28, 27, 27));
	}
	
	for (int i = 0; i < iconList.size(); i++) {
		BufferedImage bb = iconList.get(i);
		BufferedImage b2 = new BufferedImage(27, 27, BufferedImage.TYPE_INT_ARGB);
		
		int oldRGB = new Color(155, 232, 224).getRGB();

		for (int x = 0; x < bb.getWidth(); x++) {
			for (int y = 0; y < bb.getHeight(); y++) {
				if (bb.getRGB(x, y) != oldRGB) {
					b2.setRGB(x, y, bb.getRGB(x, y));
				}
			}
		}
	    
	    iconList.set(i, b2);
	}
}
 
开发者ID:Detea,项目名称:PekaED,代码行数:45,代码来源:SetMapPositionDialog.java

示例15: isPaintValid

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
 * Returns true if the given TexturePaint instance can be used by the
 * accelerated BufferedPaints.Texture implementation.
 *
 * A TexturePaint is considered valid if the following conditions
 * are met:
 *   - the texture image dimensions are power-of-two
 *   - the texture image can be (or is already) cached in a D3D
 *     texture object
 */
@Override
public boolean isPaintValid(SunGraphics2D sg2d) {
    TexturePaint paint = (TexturePaint)sg2d.paint;
    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    BufferedImage bi = paint.getImage();

    // verify that the texture image dimensions are pow2
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)dstData.getDeviceConfiguration().getDevice();
    int imgw = bi.getWidth();
    int imgh = bi.getHeight();
    if (!gd.isCapPresent(CAPS_TEXNONPOW2)) {
        if ((imgw & (imgw - 1)) != 0 || (imgh & (imgh - 1)) != 0) {
            return false;
        }
    }
    // verify that the texture image is square if it has to be
    if (!gd.isCapPresent(CAPS_TEXNONSQUARE) && imgw != imgh)
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this is a hack that attempts to cache the system
        //         memory image from the TexturePaint instance into a
        //         D3D texture...
        srcData =
            dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // verify that the source surface is actually a texture
    D3DSurfaceData d3dData = (D3DSurfaceData)srcData;
    if (d3dData.getType() != D3DSurfaceData.TEXTURE) {
        return false;
    }

    return true;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:56,代码来源:D3DPaints.java


注:本文中的java.awt.image.BufferedImage.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。