fread memory size limit

This is a discussion on fread memory size limit within the C Programming forums, part of the General Programming Boards category; If you've been reading my previous thread, you're familiar with me trying to work with BMP's, which works so far ...

  1. #1
    Registered User 3Nex's Avatar
    Join Date
    May 2010
    Location
    Croatia
    Posts
    13

    fread memory size limit

    If you've been reading my previous thread, you're familiar with me trying to work with BMP's, which works so far for small images. But that was just testing my program and now that I have to move on to the real images (527x390), it's becoming evident that it will cause problems. For a problem I first carelesslly thought that fseek() caused (making all data zeroes), it was actually fread()'s fault. I've narrowed it down to the sizes somewhere between 3162 and 3689 bytes. The size I need is 616590 bytes (527x390x3colors).

    So, basically I can read 0.5% of the whole image for now...

    Is there a workaround to let the compiler know that I need that much more much before I dive into splitting all that data into several structures (i don't even know how I'm gonna do that)? Or is there a totally different approach you would recommend?
    Last edited by 3Nex; 05-22-2010 at 07:20 AM.

  2. #2
    Registered User 3Nex's Avatar
    Join Date
    May 2010
    Location
    Croatia
    Posts
    13
    Oh crap! I solved it... Stupid me, it was so simple.

    Instead of
    Code:
    fread(&dots, sizeof(dots), WIDTH*HEIGHT, image);
    I've put
    Code:
    for(i=0;i<HEIGHT;i++) {
            fread(&dots, sizeof(dots), WIDTH, image);
        }
    and it works...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Available memory size
    By Opariti in forum Windows Programming
    Replies: 17
    Last Post: 10-06-2009, 01:06 AM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  3. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM
  4. Memory size
    By a_learner in forum C Programming
    Replies: 4
    Last Post: 10-08-2001, 08:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21