1. 从byte[]得到Image

  1. private static Image createImage(byte[] imageBytes) {
  2. Image image = null;
  3. try {
  4. ByteArrayInputStream bais = new ByteArrayInputStream(imageBytes);
  5. image = new Image(null, bais);
  6. } catch (Exception e) {
  7. e.printStackTrace();
  8. }
  9. return image;
  10. }

2. 从Image得到byte[]

public static byte[] getImageBytes(Image image) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();

ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] { image.getImageData() };
imageLoader.save(baos, image.type);

byte[] imageByteArray = baos.toByteArray();
try {
baos.close();
} catch (Exception e) {
e.printStackTrace();
}

return imageByteArray;
}

swt byte[] 与 Image的转换的更多相关文章

  1. C# Byte[] 转String 无损转换

    C# Byte[] 转String 无损转换 转载请注明出处 http://www.cnblogs.com/Huerye/ /// <summary> /// string 转成byte[ ...

  2. OpenCV中IplImage图像格式与BYTE图像数据的转换

    最近在将Karlsruhe Institute of Technology的Andreas Geiger发表在ACCV2010上的Efficent Large-Scale Stereo Matchin ...

  3. 关于C# byte[]与struct的转换

    转自:http://blog.chinaunix.net/uid-215617-id-2213082.html Some of the C# code I've been writing recent ...

  4. byte与sbyte的转换

    C#实现byte与sbyte的转换 byte[] mByte; sbyte[] mSByte = new sbyte[mByte.Length]; ; i < mByte.Length; i++ ...

  5. Java - byte[] 和 String互相转换

    通过用例学习Java中的byte数组和String互相转换,这种转换可能在很多情况需要,比如IO操作,生成加密hash码等等. 除非觉得必要,否则不要将它们互相转换,他们分别代表了不同的数据,专门服务 ...

  6. C#string byte[] base64位互相转换

    byte表示字节,byte[]则表示存放一系列字节的数组 1个字符=2个字节(byte) 1个字节=8个比特(bit) 网速上所说的1M其实是指1兆的小b,1M= 1024b/8 = 128kb 下面 ...

  7. php byte数组与字符串转换类

    <?php /** * byte数组与字符串转化类 * @author ZT */ class Bytes { /** * 转换一个string字符串为byte数组 * @param $str ...

  8. java byte 16进制转换

    整型转16进制: int devIdInt = Integer.parseInt(devId);String devIdString = Integer.toHexString(devIdInt); ...

  9. java乱码详解(java中byte与char的转换)

    转自:http://hi.baidu.com/%C6%F3%D2%B5%BC%D2%D4%B0/blog/item/825a4858d6248e8b810a181a.html   java byte与 ...

随机推荐

  1. php YAF

    Yaf 的特点: 用C语言开发的PHP框架, 相比原生的PHP, 几乎不会带来额外的性能开销. 所有的框架类, 不需要编译, 在PHP启动的时候加载, 并常驻内存. 更短的内存周转周期, 提高内存利用 ...

  2. git warning解决方案

    1.warning: LF will be replaced by CRLF in xxxxx. 设置: git config core.autocrlf false

  3. Oracle横向纵向汇总

    Oracle横向纵向汇总 有一张表test 如下, (NO 学生编号 ,cj 成绩) NO name KM CJ 001 张三 语文 80  001 张三 数学 86  001 张三 英语 75  0 ...

  4. js实现表格信息的删除和添加

    制作一个表格,显示班级的学生信息. 要求: 1. 鼠标移到不同行上时背景色改为色值为 #f2f2f2,移开鼠标时则恢复为原背景色 #fff 2. 点击添加按钮,能动态在最后添加一行 3. 点击删除按钮 ...

  5. Introduction to Project Management(II)

    Introduction The purpose of this paper is to gain an understanding of project management and to give ...

  6. li有无缩略图样式调取

    <div class="part3list">[field:array runphp='yes']@me = (strpos(@me['litpic'],'defaul ...

  7. 最新AndroidSDK安装教程

    很多人都有安卓sdk安装的疑问,现在我就将步骤详细的介绍,那就直接进入正题吧. 工具/原料   Android SDK 方法/步骤     下载最新的Android SDK 文件,到官网选择自己想要的 ...

  8. RabbitMQ学习总结 第五篇:路由Routing

    目录 RabbitMQ学习总结 第一篇:理论篇 RabbitMQ学习总结 第二篇:快速入门HelloWorld RabbitMQ学习总结 第三篇:工作队列Work Queue RabbitMQ学习总结 ...

  9. [BS-17] iOS开发-Alpha,Hidden和Opaque区别

    iOS开发-Alpha,Hidden和Opaque区别   UIView控件都有Alpha,Hidden和Opaque这三个常见属性,UIView控件BackgroundColor是用RGBA表示的, ...

  10. Android --ListView分页

    参考博客:Android ListView分页加载(服务端+android端)Demo 监听OnScrollListener事件 class OnListScrollListener implemen ...