androidbyte转图片
㈠ android 点击一张图片把图片的信息传到下一个activity图片是一个byte[]
Bundle.putByteArray(key,value);第一个activity 调用这个方法把bundle 放到 intent 当中,第二个通过key 值取出来。
㈡ android如何由数组保存成图片并保存在SD卡上
Bitmap bm = BitmapFactory.decodeByteArray(byte[] data, int offset, int length);别忘了判断数组是不是为空。
保存。。。。
public void saveFile(Bitmap bm, String fileName) throws IOException {
private final static String ALBUM_PATH
= Environment.getExternalStorageDirectory() + "/download_test/";
File dirFile = new File(ALBUM_PATH);
if(!dirFile.exists()){
dirFile.mkdir();
}
File myCaptureFile = new File(ALBUM_PATH + fileName);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
}
㈢ android如何把byte数据存到内存中并转为bitmap,求高手~~~~~~~~~~~~~~~~~~~~~~~~~~~
import java.io.File;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class MainAct extends Activity {
private ImageView img;
//图片路径
private String filepath = "/sdcard/sample.jpg";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
img = (ImageView) findViewById(R.id.img);
File file = new File(filepath);
if (file.exists()) {
Bitmap bm = BitmapFactory.decodeFile(filepath);
//将图片显示到ImageView中
img.setImageBitmap(bm);
}
}
}
请参考
㈣ 在Android中如何将一张图片转换为byte数组
LZ,我比较好奇,你有木有试过将你得到的filebuffer再转化成bitmap,看看它显示出来的有木有变化?
㈤ Android Byte[]数组转Bitmap时图像失真,有些花 请问怎么解决 急急急 !! 求大神
你把转换前后的值都用System.out()输出来,查看一下数值有没有变化
㈥ android中如何将drawable中的图片内容读取出来并转换为byte数据形式。 最好有代码可以参考的
Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
baos.toByteArray();
希望你能帮到你
㈦ android byte[]转化成bitmap 发生了错误,要如何解决呢大神快来呀 高悬赏
建议使用BitmapFactory的其他decode方法,如果是网络读过来的流,最好在本地存成文件缓存,然后通过decodeFileDescriptor方法就没这种问题了。
你可以看一下这里 http://www.thinksaas.cn/group/topic/203384/,也碰到了类似的问题
㈧ android byte转图片问题,为什么图片没有显示,程序也没有报错
每种格式的文件都有不一样的文件头,扩展名之类的只是让系统知道用何种软件可以打开
至于文件格式是在文件头里面的,所以你的会是空
㈨ android 图片以byte[]形式存入mysql数据库,取出来后为空值。
这里需要的byte[]不是普通的,是:EntityUtils.toByteArray(entity)形式的。
㈩ Android 图片以字节流方式存入本地数据库 怎么弄 求高手指点啊
少年,数据库有个类型是blob,可以用这个类型存储,直接存储字节,步骤:
1.假设图片字段名Image,那么设置Image为blob字段
2.代码中将bimageview转换为字节以后,用ContentValues中的values.put("Image",byte[]);然后或者是插入,或者是更新,用android的sqlite3中的操作就可以了
如果你看上面的后半部分不太懂,可以网络一下:android sqlite3 的增删改查,就会看到里面有具体的步骤了,就是利用ContentValues进行sql语句处理