Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to I view in image, based on code? libpng...c... not sure...?
I have a file, *.c file, that I believe is an image....but its in this format... I know libpng has something to do with it. When I open it in VS, I get the following....
"const unsigned char background_png[] __attribute__ ((section (".cdat"))) = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x94, 0x08, 0x02, 0x00, 0x00, 0x00, 0x59, 0x76, 0xf1,
0x45, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61,...............
.......0x9d, 0x96, 0x52, 0x2b, 0x9e, 0xd8, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82
};
const int background_png_size = sizeof background_png;"
Basically, I wanna know a way to compile this into an editable image.
I have multiple other images like this as well....
Any help with a program or whatever to figure this out would be awesome!
2 Answers
- satsumoLv 51 decade agoFavorite Answer
It is a PNG image. The first 8 bytes are 'PNG\r\n \n' which is a PNG file signature. The next four bytes are the size of the header chunk followed by 'IHDR'. All of that says it a PNG file.
The code describes a PNG file as data in memory, if you compiled it you would get a C object file, which has lots of other data beside the compiled code. It wouldn't be a PNG file.
Easiest way I can think of is to just add a bit of code that writes the data to disk. Something like this -
#include <stdio.h>
int main (void)
{
FILE *fp = fopen ("background.png", "wb");
if ((fp)
{
fwrite (background_png, background_png_size, 1, fp);
fclose (fp);
}
return 1;
}
Make an executable from that and run it. It will make the PNG file.
- 1 decade ago
maybe the file cant be compiled. But it is read by a specific program. it does have the pixel information (the "0xc8" and so, i think) so you need to convert that one into a pixel (write a program to redraw it by using the above information)