像素点运算java源代码 像素点运算java源代码是什么( 三 )


{
case(1):
g.drawLine(n+i,j,n+i,j);
}
}
}
/*char b[]={0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0};
{
int j=11;
int i=3;
{
for (int n=0;n=9;n++)
switch (b[n])
{
case(1):
g.drawLine(n+i,j,n+i,j);
}
}
}
{
int j=25;
int i=11;
{
for (int n=0;n=9;n++)
switch (b[n])
{
case(1):
g.drawLine(i,j-n,i,j-n);
}
}
}*/
}
}
关于通过java获取图片像素点时出现 java.lang.OutOfMemoryError: Java heap space 问题没有发现好像素点运算java源代码的办法像素点运算java源代码 , 不过可以试一下调整eclipse jvm内存 。
设置 eclipse.ini 加入下面选项
-vmargs
-Xms128M
-Xmx512M
-XX:PermSize=64M
-XX:MaxPermSize=128M
你可以根据具体情况修改那些数字 。
当然还有其他办法调整eclipse jvm内存,也要根据你使用的eclipse 来调整 。
Java如何读取BMP的每个像素点,输出到一个二维数组楼上的基本正确,
问题一:
int[] rgb = new int[3];最好用二维数组
int[] rgb = new int[3][width*height]
问题二:
rgb[0] = (pixel0xff0000 )16 ;
rgb[1] = (pixel0xff00 )8 ;
rgb[2] = (pixel0xff );
会把数组内的值覆盖,获得就是最后像素点的RGB值;
我写了一个希望可以帮助到你
package imageReadAndWrite;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* JPG File reader/writer. Uses native com.sun libraries (which may deprecate at
* any time)
*
*
* @author PhoenixZJG
* @version 1.0
*/
public class JPGFile implements xxxFile {
private int[] ints = null;
private byte bytes[] = null; // bytes which make up binary PPM image
private double doubles[] = null;
private int[][] imageRGB = null;
private String filename = null; // filename for PPM image
private int height = 0;
private int width = 0;
/**
* Read the PPM File.
*
* @throws FileNotFoundException
*if the directory/image specified is wrong
* @throws IOException
*if there are problems reading the file.
*/
public JPGFile(String filename) throws FileNotFoundException, IOException {
this.filename = filename;
readImage();
}
/**
* Get the height of the PPM image.
*
* @return the height of the image.
*/
public int getHeight() {
return height;
}
/**
* Get the width of the PPM image.
*
* @return the width of the image.
*/
public int getWidth() {
return width;
}
/**
* Get the data as byte array. Data is of any type that has been read from
* the file (usually 8bit RGB)
*
* @return The data of the image.
*/
public byte[] getBytes() {
return bytes;
}
/**
* Get the data as double array. Data is of any type that has been read from
* the file (usually 8bit RGB put into an 64bit double)
*
* @return The data of the image.
*/
public double[] getDouble() {
return doubles;
}
/**
* Get the data as double array. Data is of any type that has been read from
* the file (usually 8bit RGB put into an 64bit double)
*
* @return The data of the image.
*/
public int[] getInt() {
return ints;
}
/**
* Get the data as integer array. Data is of any type that has been read from

推荐阅读