GIMP RGBA C源图像转储 [英] GIMP RGBA C-Source image dump

查看:105
本文介绍了GIMP RGBA C源图像转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何将GIMP的输出读入图像吗?

Does anyone know how to read this output from GIMP into an Image?

/* GIMP RGBA C-Source image dump (Smiley.c) */

static const struct {
  guint  	 width;
  guint  	 height;
  guint  	 bytes_per_pixel; /* 3:RGB, 4:RGBA */ 
  guint8 	 pixel_data[15 * 15 * 4 + 1];
} gimp_image = {
  15, 15, 4,
  "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\370\345\261\377"
  "\362\314f\377\357\300C\377\356\2735\377\357\300C\377\362\314f\377\370\345"
  "\261\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
  "\377\0\377\377\377\0\373\362\332\377\357\305W\377\360\307R\377\371\341\211"
  "\377\375\354\242\377\377\362\256\377\375\354\242\377\371\341\211\377\360"
  "\307R\377\357\305W\377\373\362\332\377\377\377\377\0\377\377\377\0\377\377"
  "\377\0\372\361\332\377\353\276H\377\365\330r\377\377\354\231\377\377\352"
  "\231\377\377\353\241\377\377\354\243\377\377\353\241\377\377\352\231\377"
  "\377\354\231\377\365\330r\377\353\276H\377\372\361\332\377\377\377\377\0"
  "\377\377\377\0\351\277W\377\364\325g\377\346\301Y\377\273\210\"\377\273\210"
  "\"\377\345\304k\377\376\347\227\377\345\304k\377\273\210\"\377\273\210\""
  "\377\346\301Y\377\364\325g\377\351\277W\377\377\377\377\0\363\340\261\377"
  "\350\275G\377\376\336i\377\360\311T\377\343\272O\377\343\274T\377\361\315"
  "i\377\376\337}\377\361\315i\377\343\274T\377\343\272O\377\360\311T\377\376"
  "\336i\377\350\275G\377\363\340\261\377\345\277f\377\223|4\3773*\20\377\230"
  "\224\207\377LLL\377\12\24\37\3770(\21\377\213p,\3770(\21\377\205\212\217"
  "\377LLL\3770'\17\3773*\20\377\223|4\377\345\277f\377\334\255C\377\371\323"
  "\\\377:2\27\377XQ<\377CCC\377'1;\3778/\27\377\342\261;\3778/\27\377CLT\377"
  "CCC\377@7\40\377:2\27\377\371\323\\\377\334\255C\377\325\2425\377\374\322"
  "U\377\231w*\377SJ3\377SJ3\377SJ4\377\275\2233\377\356\271:\377\275\2233\377"
  "SJ4\377SJ3\377SJ3\377\230v)\377\374\322U\377\325\2425\377\323\244C\377\366"
  "\310M\377\357\2675\377\341\2531\377\341\2532\377\341\2533\377\364\275<\377"
  "\372\303@\377\364\275<\377\341\2533\377\341\2532\377\341\2531\377\357\267"
  "5\377\366\310M\377\323\244C\377\326\260f\377\352\271D\377\371\2758\377\371"
  "\277;\377\372\300@\377\372\302D\377\372\303F\377\372\303G\377\372\303F\377"
  "\372\302D\377\372\300@\377\371\277;\377\371\2758\377\352\271D\377\326\260"
  "f\377\346\323\261\377\314\2317\377\371\277?\377\371\276@\377\273\210\"\377"
  "\362\275K\377\372\307V\377\372\307W\377\372\307V\377\372\305Q\377\371\302"
  "I\377\371\276@\377\371\277?\377\314\2317\377\346\323\261\377\377\377\377"
  "\0\301\227W\377\333\245=\377\371\300H\377\352\265H\377\273\210\"\377\273"
  "\210\"\377\273\210\"\377\273\210\"\377\343\261H\377\372\305U\377\371\300"
  "H\377\333\245=\377\301\227W\377\377\377\377\0\377\377\377\0\360\347\332\377"
  "\267\210D\377\330\242C\377\371\306[\377\372\313f\377\372\316l\377\372\316"
  "n\377\372\316l\377\372\313f\377\371\306[\377\330\242C\377\267\210D\377\360"
  "\347\332\377\377\377\377\0\377\377\377\0\377\377\377\0\352\343\332\0\271"
  "\217W\377\274\210;\377\337\254O\377\360\277]\377\370\307b\377\360\277]\377"
  "\337\254O\377\274\210;\377\271\217W\377\352\343\332\0\377\377\377\0\377\377"
  "\377\0\377\377\377\0\354\354\354\0\325\325\325\"\312\310\306\377\267\250"
  "\225\377\264\217]\377\257\200B\377\253x5\377\257\200B\377\264\217]\377\267"
  "\250\225\377\314\312\310\356\336\336\336\0\377\377\377\0\377\377\377\0",
};



谢谢,
Don



Thanks,
Don

推荐答案

如果这是XCF,则希望对您有所帮助:http://svn.gnome.org/viewvc/gimp/trunk/devel-docs/xcf.txt?view=markup [ ^ ].

但是,您需要使用本机格式还是可以直接从GIMP保存为例如JPEG?
If that''s XCF, this would hopefully help: http://svn.gnome.org/viewvc/gimp/trunk/devel-docs/xcf.txt?view=markup[^].

However, do you need to use native format or could you save directly to for example JPEG from GIMP?


我不确定该格式是什么.

基本上,我希望将一幅小图像硬编码到我的代码中.我不想从外部文件中读取图像.我尝试 C#图像到字节数组和字节数组到图像转换器类来从以下数组读取图像个字节,但图像质量下降.

我发现GIMP已保存为上面的.c文件,但我不知道如何将其放入图像. GIMP也可以另存为.h,但这甚至更加晦涩难懂.我看到GIMP还将所有像素rgb值另存为.htm.我会将这些rgb格式化为数组以读取.

等待一分钟,返回到 C#图像到字节数组和字节数组到图像转换器类.我看到将其设置为 ImageFormat.Gif 并将其更改为 ImageFormat.Png 可以修复质量.所以我再给这张照片.
I''m not sure what format it is in.

Basically I want a small image to be hard encoded into my code. I don''t want to read the image in from an external file. I tried C# Image to Byte Array and Byte Array to Image Converter Class to read the image from an array of bytes, but it lost quality in the image.

I found that GIMP saved as the .c file above but I don''t know how to get it into an Image. GIMP can also save as .h but that''s even more cryptic. I see that GIMP also saves as .htm with all the pixel rgb values in it. I''ll format those rgb''s into an array to read in.

Wait a minute, back to C# Image to Byte Array and Byte Array to Image Converter Class. I see that the it was set to ImageFormat.Gif and changing it to ImageFormat.Png fixed the quality. So I''ll give that another shot.


如果您只是想将图像嵌入可执行文件中(即不在运行时加载它),则不需要将图像编码成这样的代码.

您只需要在Visual Studio中将图像添加为资源,然后就可以在代码中以System.Drawing.Bitmap的形式使用它.

请参见链接资源与嵌入式资源 [如何添加或删除资源 [访问应用程序资源 [
If you''re just wanting to embed the image into your executable (i.e. not load it at runtime), you don''t need to encode the image into code like this.

You just need to add the image as a resource in Visual Studio, and it will then be available to you in code as a System.Drawing.Bitmap.

See Linked vs. Embedded Resources[^]
How to Add or Remove Resources[^]
Accessing Application Resources[^]

In your case you would save the image as a PNG, GIF, JPG, TIF, etc. and then add it as a resource. Any of those will be available to you in code as a Bitmap.


这篇关于GIMP RGBA C源图像转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆