转rgb565

private void genRGB565()
	{
		Bitmap mBitmap = BitmapFactory.decodeFile("/sdcard/test.jpg");
		Bitmap mRGB565Bitmap = mBitmap.copy(Bitmap.Config.RGB_565, false);
		
		//String mRGB565FileName = "frameworks.raw";
		//String mRGB565FilePath = mDirectory + "/" + mRGB565FileName;
		int mBitmapSize = mBitmap.getWidth() * mBitmap.getHeight() * 4;
		Log.e("JavaTest", "ready to gen rgb565");
		try {
			  File rgb565File = new File("/sdcard/rgb565.raw");
			  OutputStream ops = new FileOutputStream(rgb565File);
			  ByteBuffer mBuf = ByteBuffer.allocate(mBitmapSize);
			  mRGB565Bitmap.copyPixelsToBuffer(mBuf);
			  ops.write(mBuf.array());
		} catch (IOException ex) {
			 Log.e("JavaTest", "can not open frameworks.raw");
		}
	}


你可能感兴趣的:(java)