Tag: bmp

如何使用ColorQuantizerDescriptor?

按照@ PhiLho回答如何将BufferedImage转换为8位的想法? ,我想使用ColorQuantizerDescriptor转换BufferedImage ,imageType TYPE_INT_RGB,但RenderedOp#getColorModel()抛出以下exception: java.lang.IllegalArgumentException:指定的ColorModel与图像SampleModel不兼容。 在javax.media.jai.PlanarImage.setImageLayout(PlanarImage.java:541) 在javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878) 在javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2253) 这是我试图使用的代码: final RenderedOp medianCutQuantizerOp = ColorQuantizerDescriptor.create(rgbImage, ColorQuantizerDescriptor.MEDIANCUT, 256, null, null, null, null, null); final BufferedImage bi = medianCutQuantizerOp.getAsBufferedImage(null, medianCutQuantizerOp.getColorModel()); 我如何使用ColorQuantizerDescriptor ?

如何读取.bmp文件来识别Java中哪些像素是黑色的

像下面的东西…除了使其工作: public void seeBMPImage(String BMPFileName) throws IOException { BufferedImage image = ImageIO.read(getClass().getResource(BMPFileName)); int[][] array2D = new int[66][66]; for (int xPixel = 0; xPixel < array2D.length; xPixel++) { for (int yPixel = 0; yPixel > 23) == 1) { array2D[xPixel][yPixel] = 1; } else { array2D[xPixel][yPixel] = 1; } } } }

java Buffered Image:检测黑色像素

我有这个简单的代码来通过24位彩色windows bmp文件 BufferedImage mapa = BMPDecoder.read(new File(“maps/map.bmp”)); final int xmin = mapa.getMinX(); final int ymin = mapa.getMinY(); final int ymax = ymin + mapa.getHeight(); final int xmax = xmin + mapa.getWidth(); for (int i = xmin;i<xmax;i++) { for (int j = ymin;j<ymax;j++) { int pixel = mapa.getRGB(i, j); if (pixel == 0) { System.out.println("black at […]

从独立于开源平台的Java代码替换Windows * .exe中的图标

首先,这不是从Java类生成EXE的常见问题的重复。 我不需要这样做。 要解决NetBeans RFE#64612而不需要手动步骤,我需要一个Java(6+)库,它可以获取现有的 Windows *.exe文件,并用通用格式的替换替换其图标。 可执行文件是通用的并且是预构建的(以二进制forms分发),已经知道如何加载特定于应用程序的配置文件,然后使用各种应用程序JAR等启动JRE。 唯一的问题是它有一个通用图标,我想将该图标替换为纯Java构建的一部分,并带有特定于应用程序的图标,因此它看起来更漂亮。 该库必须在非病毒开源许可下提供; 跨平台(必须在Windows,Linux,Mac,Solaris上运行),因此无法分叉某些特定于操作系统的帮助工具; 并且必须接受PNG输入,尽管EXE必须在XP上工作,因此根据Wikipedia应该嵌入BMP格式。 在高层次上,假设Ant作为构建工具,我想要这样的东西: 有谁知道是否已经存在符合这些规范的工具? 从各种网络搜索我发现Launch4J ,但这似乎只是为实际工作分叉,因此不是简单的便携式。 我发现JSmooth看起来更有前途 – 似乎包含了处理ICO编解码器和操作PE文件的Java代码 – 但它是GPL。 WinRun4J看起来使用本机代码进行图标操作,尽管我很难跟踪它的来源。 据说吉米处理ICO格式(标准的javax.imageio似乎也是这样)但我想没有更新PE资源的工具。

Javax ImageIO IIO例外显然没有理由

嘿所有,我有一个Java问题。 对于我的高级研究class,我已经完成了,但我只需要分析我生成的图像中的一些数据。 我不想把它标记为作业,因为它不是任何必要任务的一部分……这是我自己想出来收集结果的东西。 我写了一个程序,逐个像素地比较两个图像。 它为两个目录中的所有.bmp文件执行此操作。 现在,我的程序将文件名读入一个String数组,并检查了所有文件名的值,所以我知道目录和文件名最初是正常访问的。 这是有问题的代码: public static void main(String[]args) throws IOException { File actualDir = new File(“C:\\Users\\Rowe\\Desktop\\testExpect”); String actualFiles[] = actualDir.list(); File expectedDir = new File(“C:\\Users\\Rowe\\Desktop\\testExpect2”); String expectedFiles[] = expectedDir.list(); int[][] stats = new int[actualFiles.length][6]; // Holds all info //Columns, Rows, Total, redMatches, shouldaBeenRed, badRed for(int i = 0; i < actualFiles.length; i++) […]

在java中将bmp转换为jpg

你如何在Java中将bmp转换为jpg? 我知道如何使用ImageIO方式但是有更快或更好的方法吗? 这是我在网上找到的ImageIO方式。 `//Create file for the source File input = new File(“c:/temp/image.bmp”); //Read the file to a BufferedImage BufferedImage image = ImageIO.read(input);` //Create a file for the output File output = new File(“c:/temp/image.jpg”); //Write the image to the destination as a JPG ImageIO.write(image, “jpg”, output); 如果我用这种方式,我会失去质量吗? 谢谢

在JLabel中显示BMP

Java可以显示png,jpg等一些其他图片格式,但我必须通过获取文件路径在JLable中显示bmp文件。 ImageIcon imageIcon = new ImageIcon(imageFile.getAbsolutePath()); ImageIcon支持典型的png,gif,jpg图像。 在我正在工作的项目中,我无法打开bmp文件并将相同的文件存储为jpg,因为我不允许在运行时存储某些内容。 我只能在内存中生成图像。 但我不知道该怎么做。 如何在Java 1.4显示BMP ? 谢谢

Java中的BMP BufferedImage

我有一个BufferedImage对象,我想将其编码为BMP格式并将其保存到磁盘。 我该怎么做呢? 在JPEG它没关系: BufferedImage img; //here is an image ready to be recorded into the hard disk FileOutputStream fout = new FileOutputStream(“image.jpg”); JPEGImageEncoder jencoder = JPEGCodec.createJPEGEncoder(fout); JPEGEncodeParam enParam = jencoder.getDefaultJPEGEncodeParam(img); enParam.setQuality(1.0F, true); jencoder.setJPEGEncodeParam(enParam); jencoder.encode(img); fout.close();

Android:将位图保存为bmp文件格式

我在内存中有一个Bitmap,我需要将它保存在bmp文件中(使用bmp文件格式 )。 有没有办法在Android上做到这一点? (我读了很多post建议使用png格式 – 这是无损 – 但是,这不是我需要的:我真的需要bmp格式 )。 我已经有一些代码使用Bitmap.compress方法将其保存在jpeg或png中: /** * Save data to file using format. * When format is null : the bitmap will be saved in bmp format **/ public void writeBitmapToFile(Bitmap data, File file, Bitmap.CompressFormat format) { FileOutputStream os = null; try { os = new FileOutputStream(file); if(format==null){ //TODO : […]