Jump to content

Recommended Posts

Posted

Boas pessoal estou com uma duvida. Gostaria de saber se era possível por exemplo incluir uma imagem no meu projecto e depois ficar tudo apenas num executavel e em tempo de execução essa imagem seria extraida. Algum sabe como isto pode ser feito em C ou C++?

Posted (edited)
char imagem[] = "\x00\x01...\xFF";

Depois abres um ficheiro e escreves os dados para la

/* falta error checking! */
f = fopen("image.png", "wb");
fwrite(imagem, 1, sizeof imagem, f);
fclose(f);
Edited by pmg

What have you tried?

Não respondo a dúvidas por PM

A minha bola de cristal está para compor; deve ficar pronta para a semana.

Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!

Posted (edited)

char imagem[] = "\x00\x01...\xFF";

Isto é o codigo hex do ficheiro?

Podes dizer que sim.

Em Unix tens um utilitario (xxd) que faz isso automaticamente

$ xxd -i image.png
unsigned char image_png[] = {
 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00,
/* ... ... ... */
 0xfe, 0x0f, 0x26, 0xd6, 0xf2, 0x8b, 0x67, 0xbe, 0x77, 0xd5, 0x00, 0x00,
 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
unsigned int image_png_len = 205426;
Edited by pmg

What have you tried?

Não respondo a dúvidas por PM

A minha bola de cristal está para compor; deve ficar pronta para a semana.

Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.