3814|6

1803

帖子

0

TA的资源

五彩晶圆(高级)

楼主
 

LM3S9B96 图片转换成数组 [复制链接]

有网友问到 LM3S9B96 图片转换成数组的方法。找到一个文档,大家可以试试。
This program converts an image in NetPBM format into a C structure definition
for a tImage that can be passed to the GrImageDraw() function.  Only the binary
PPM format (indicated by format code "P6") is supported by the program.

The NetPBM (http://netpbm.sourceforge.net) or ImageMagick
(http://www.imagemagick.org) packages may be used to convert image from other
formats (such as PNG, JPEG, or BMP) to a PPM.  They may also be used to scale
the image and reduce the number of colors as required by the application.

Using NetPBM as an example, given an image foo.jpg, the following steps are
used to convert it to something usable by the GrImageDraw() function:

1) "jpegtopnm foo.jpg > foo.pnm"

   This step converts the JPEG to a PNM, preparing it for further processing by
   the NetPBM tools.  Alternatively "bmptopnm", "pngtopnm", or "giftopnm" (or
   many others) can be used to convert other image formats to a PNM.  If
   starting from a PNM that is not in the required format, "pnmtopnm" will
   convert the file to the required PPM format.

2) "pamscale -width 64 -height 48 foo.pnm > foo_sm.pnm"

   Scale the image to 64 pixels wide by 48 pixels tall.  This is an optional
   step that is not needed if the image is already the required size.

3) "pnmcolormap 16 foo_sm.pnm > foo_cm.pnm"

   Produces a colormap of the 16 colors that can be used to best represent the
   color content in the image.  This colormap is used in the next step to
   reduce the amount of color content in the image.  If the image was
   constructed with the correct number of colors from the start, then this step
   (and the next) can be skipped.

   Changing the first argument (16 in this example) will change the number of
   colors in the colormap.  More colors provides better image color quality (in
   very colorful images) at the cost of more storage.  Note that 256 is the
   maximum number of colors that can be utilized by GrImageDraw().

4) "pnmremap -mapfile=foo_cm.pnm foo_sm.pnm > foo_img.pnm"

   Use the colormap produced in step 3 and set each pixel of the image to be
   the closest color in the colormap to the original pixel.  After this
   mapping, the image will only have the number of colors selected in the
   colormap.

5) "pnmtoc -c foo_img.pnm > foo.c"

   Convert the resulting PNM to a C array in foo.c, using compression.  The
   resulting file provides a structure definition for "g_sImage", which will
   likely require hand editing to be a more indicative name (and avoid a name
   clash if more than one image is used).

6) "ppmtobmp foo_img.pnm > foo_test.bmp"

   Convert the final PNM to a BMP for local examination.  Viewing the resulting
   image (after scaling and color reduction) on a PC will usually be quicker
   and easier, making it faster to try a variety of sizes and colormap sizes
   until an image of acceptable quality is produced.  This step is optional,
   though.

Any number of open source and commercial image manipulation program can perform
the equivalent operations (and even more sophisticated operations).

最新回复

我是用"bmptopnm",命令把bmp格式的图片转成pnm的,然后用用pamscale缩放到240×320像数,然后直接用TI的工具pnmtoc显示“Image contains too many colors”,然后用pnmcolormap生成128色的pnm,但是老是出错,不管是生成64色,128色,256色都出现错误,这个是什么原因啊  详情 回复 发表于 2012-7-11 16:18
 
点赞 关注

回复
举报

3836

帖子

19

TA的资源

纯净的硅(中级)

沙发
 
谢谢楼主分享 呵呵
 
 

回复

1803

帖子

0

TA的资源

五彩晶圆(高级)

板凳
 

回复 沙发 fish001 的帖子

大家如果找到了 NetPBM  这个工具,可以传上来共享一下。

[ 本帖最后由 Study_Stellaris 于 2012-2-14 10:19 编辑 ]
 
 
 

回复

424

帖子

0

TA的资源

纯净的硅(高级)

4
 
可以用GIMP将PNG文件转换成PNM,然后通过pnmtoc工具,导出数组。
 
 
 

回复

1万

帖子

16

TA的资源

版主

5
 

谢谢分享

 
个人签名http://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 

回复

79

帖子

0

TA的资源

一粒金砂(高级)

6
 
能翻译成中文吗
 
 
 

回复

17

帖子

0

TA的资源

一粒金砂(中级)

7
 
我是用"bmptopnm",命令把bmp格式的图片转成pnm的,然后用用pamscale缩放到240×320像数,然后直接用TI的工具pnmtoc显示“Image contains too many colors”,然后用pnmcolormap生成128色的pnm,但是老是出错,不管是生成64色,128色,256色都出现错误,这个是什么原因啊
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/6 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表