Huge File

This is a discussion on Huge File within the C Programming forums, part of the General Programming Boards category; Any clue to how to directly read and modify a file in disk without loading it into memory? I have ...

  1. #1
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489

    Huge File

    Any clue to how to directly read and modify a file in disk without loading it into memory?

    I have many huge images, and I need to view them inside a viewport without hogging the memory.

    This is my first experience to feel the real NULL pointer returned by the malloc

    I saw some of applications crashed due to my files, and yet some of capable viewer just doesn't match the requirements.

    My program runs in a 64MB RAM and 4GB HDD computer so that even windows' page file won't help.

    My plan is to divide the huge image into smaller chunks, then load it as usual with some kind of algorithm to optimize the viewing speed.

    Any clue please?

    Thanks in advance.
    Just GET it OFF out my mind!!

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Quote Originally Posted by audinue View Post
    Any clue to how to directly read and modify a file in disk without loading it into memory?
    Can't be done. To manipulate data, it has to be in memory. Period. Now, it doesn't ALL have to be in memory at the same time. You could read a byte, modify it (or not) and write it back out. If the size of the file will change, you'll have to create a shadow copy. Otherwise, you can read and write it in place.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,845
    What kind of image files (PNG, BMP, JPG)?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Quote Originally Posted by Salem View Post
    What kind of image files (PNG, BMP, JPG)?
    All of them, including TIFF and SVG one.
    Just GET it OFF out my mind!!

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> All of them, including TIFF and SVG one.

    Some file formats can be processed in chunks (such as Windows BMP) while others cannot (JPEG, for instance). I would recommend supporting as many formats as possible but have some mechanism to revert to chunked processing in the event that the file is too large.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  2. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 09:19 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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