引用:C语言:
FILE *fpImageFile;
long lBegin, lEnd;
unsigned char *pImage;
int nImageSize;
fpImageFile = fopen("a.bmp", "rb");//读取图片
lBegin = ftell(fpImageFile);
fseek(fpImageFile, 0L, SEEK_END);
lEnd = ftell(fpImageFile);
nImageSize = int(lEnd - lBegin);
pImage = new unsigned char[nImageSize];
fseek(fpImageFile, 0L, SEEK_SET);
fread(pImage, sizeof(unsigned char), nImageSize, fpImageFile);
fclose(fpImageFile);
int k=0;
for(k=0;k<10;k++){
printf("%d : %d\n",k,pImage[k]);
}
打印字符,假设前10个
0 : 66
1 : 77
2 : 202
3 : 61
4 : 7
5 : 0
6 : 0
7 : 0
8 : 0
9 : 0
-------------------------------------------------
JAVA语言:
public byte[] image2Bytes(String imagePath) throws Exception {
BufferedImage bu=ImageIO.read(new File(imagePath));
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
try {
ImageIO.write(bu, "bmp", imageStream);
} catch (Exception e) {