如题!谢谢大神!看到了!能帮我下最好了!c代码也行!我这主要是mac电脑图片压缩!
你最好是调用开源的,如:RAR 的代码,自己写压缩算法不太现实。
图片压缩无非分为两步,一个是编码方式,比如采用png jpg对位图压缩,一个是像素采样,把分辨率降低。
你可以按照这两个思路去google相应的代码。
上次看到一个网站专门压缩的效率很高。你上网搜索好像是国外的一个网站。
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;//不加载bitmap到内存中
BitmapFactory.decodeFile(mPhotoPath, options);
int outWidth = options.outWidth;
int outHeight = options.outHeight;
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inSampleSize = 1;
if (outWidth != 0 && outHeight != 0 )
{
int sampleSize=(outWidth/500+outHeight/500)/2;
options.inSampleSize = sampleSize;
}
options.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(mPhotoPath, options);
andoid 代码,不知道可不可以