Thread: reading bitmap into array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    14

    reading bitmap into array

    I have a question regarding reading a bitmap image into an array. I understand that usually the first 54 bytes of the bitmap is for the header information, and basically I need to be able to read the whole image into the array, alter the non-header parts to encrypt the image and and write the array back out into a new bitmap image. I'm not sure how to extract the height and width information nor how the reading of the bytes to an array works.

    For example, I have
    Code:
    typedef struct {
      char* data;
      char* header;
      int height;
      int width;
      int size;
    } Bitmap;
    and I want to be able to do this
    Code:
    /* The following function takes a file name and an address of
       a character array and read the file of characters into the
       array. Array and size are passed by their addresses
       Reads the BMP image from a file to an array
    */
    void readImage(char* infile, Bitmap *bitmap){
      FILE * input = fopen(infile, "br");
    
    }
    Currently I'm a little clueless and have only gotten as far as opening the file in binary, can anyone give me a few hints as to how I go about this? Thanks a lot in advance.
    Last edited by kallistine; 07-26-2009 at 09:29 AM. Reason: code tags

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-02-2009, 07:27 AM
  2. Reading a list of ints from file into an array
    By mesmer in forum C Programming
    Replies: 1
    Last Post: 11-10-2008, 06:45 AM
  3. Reading integers from a File into an Array
    By bobby19 in forum C Programming
    Replies: 13
    Last Post: 10-09-2006, 01:36 AM
  4. Reading a file into an array for fast access later
    By matsharp in forum C Programming
    Replies: 10
    Last Post: 08-03-2006, 02:42 AM
  5. Replies: 1
    Last Post: 04-25-2006, 12:14 AM