Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15272295
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2008-06-06 11:22:50

/* GIMP RGBA C-Source image dump (25.bmp.c) */
#include <stdlib.h>
#include <stdio.h>

static const struct {
  unsigned int width;
  unsigned int height;
  unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
  unsigned char pixel_data[320 * 480 * 4 + 1];
} gimp_image = {
  320, 480, 4,
  "\303\261\247\377\377\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0"
......
  "\0\0\377",
};


int main(int argc , char** argv)
{
    FILE *fp;
    fp=fopen("1.img","wb");
    fwrite(gimp_image.pixel_data, 1, sizeof( gimp_image.pixel_data)-1, fp);
    fclose(fp);
}

R是紅色,G是綠色,B是藍色,這是光線的三原色,另外A指的是透明度。不過在一般色彩學並不使用這種單位而是用『色相、彩度、明度』來表示,GIMP可以自動在這兩種模式中幫您轉換



在python中的数据显示,所以'\303'为8进制数据
>>> '\303'
'\xc3'
>>> print '%o' % (0xc3)
303
>>> '\261'
'\xb1'
>>> print '%o' % (0xb1)
261
>>>

阅读(4532) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~