Thread: Compilable image formats

  1. #16
    Registered User
    Join Date
    Jul 2008
    Posts
    58
    yes this is true, I was hoping there was a jpeg to array converter or something lol

    this way I can load things like jpegs directly intothe binary and load it in a way that I'd like

  2. #17
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by parad0x13 View Post
    yes this is true, I was hoping there was a jpeg to array converter or something lol

    this way I can load things like jpegs directly intothe binary and load it in a way that I'd like
    You're writing code, right? So why can't you create such a tool yourself?

    Here it is anyway.

    Code:
    /* anything2c.c */
    
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(int argc, char **argv)
    {
        FILE *infp;
        char *comma = "";
        int ch;
        int i;
    
        infp = fopen(argv[1], "rb");
        if(infp == NULL) exit(1);
        printf("unsigned char %s[] = {\n", argv[2]);
        while((ch = fgetc(infp)) != EOF)
        {
            printf("%s    0x%02X", comma, ch);
            comma = ",\n";
        }
        printf("\n};\n");
        fclose(infp);
        return 0;
    }
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by parad0x13 View Post
    yes this is true, I was hoping there was a jpeg to array converter or something lol

    this way I can load things like jpegs directly intothe binary and load it in a way that I'd like
    Why is this such a problem?
    Why won't the normal resource system work well for you?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Elysia View Post
    Why is this such a problem?
    Why won't the normal resource system work well for you?
    On a non-Windows system?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, there's been no mention of Linux, so I still have to ask o_O
    Besides... are there not similar systems in other operating systems, as well?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Elysia View Post
    Well, there's been no mention of Linux, so I still have to ask o_O
    Besides... are there not similar systems in other operating systems, as well?
    I was assuming some UNIX-like system because the OP mentioned XPM format.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, not familiar with XPM formats, so I did not know...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #23
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Elysia View Post
    Well, not familiar with XPM formats, so I did not know...
    XPM == "X Pixmap."
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #24
    Registered User
    Join Date
    Jul 2008
    Posts
    58
    Yes, you are right. The program will be compatible with linux and windows so I want to include the image inside the binary for ease of portability

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Replies: 1
    Last Post: 05-27-2009, 12:46 PM
  3. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 12:10 PM
  4. Custom image file formats..
    By IKG in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2007, 08:56 PM
  5. Replies: 4
    Last Post: 03-02-2003, 09:12 AM