[英]Convert C-Source image dump into original image
我用 GIMP 創建了一個 C 源圖像轉儲,如下所示:
/* GIMP RGBA C-Source image dump (example.c) */
static const struct {
guint width;
guint height;
guint bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
guint8 pixel_data[304 * 98 * 2 + 1];
} example= {
304, 98, 2,
"\206\061\206\061..... }
有沒有辦法在 GIMP 中再次讀取它以取回原始圖像? 因為這似乎不可能。 或者它是否存在可以進行這種反向轉換的工具?
恢復圖像的最簡單方法是......讓ImageMagick來做。
因此,獲取您的 C 文件並向其中添加一個main()
,它只需將 304x98x2 字節從 &(example.pixel_data) 開始寫入標准輸出:
用類似的東西編譯它:
clang example.c -o program # or with GCC
gcc example.c -o program
然后運行它,寫入ImageMagick的文件:
./program > image.bin
並告訴ImageMagick它的大小、類型、它的位置以及你想要的結果:
magick -size 304x98 RGB565:image.bin result.png
我目前還沒有 C 編譯器,並且已經有 4-5 年沒有編寫任何 C 了,但它看起來像:
#include <stdio.h>
/* tell compiler what those GIMP types are */
typedef guint int;
typedef guint8 uint8_t;
<PASTE YOUR GIMP FILE HERE>
int main(){
write(1, &(example.pixel_data), sizeof(example.pixel_data));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.