merge multiple image file into one image

This is a discussion on merge multiple image file into one image within the C++ Programming forums, part of the General Programming Boards category; hi all, now i'm doing a task adding about 36 image file with pixel 5000X5000 into one large image with ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    74

    merge multiple image file into one image

    hi all,
    now i'm doing a task adding about 36 image file with pixel 5000X5000 into one large image with pixel about 30000X42000. i use GDI + , adding image pointer into graphics object by drawimage with different coordination, but i got out of memory for the graphics object when 9th image is drawn to it. also the final image saved is damaged, i think gdi+ cannot handle such large image.
    So, is there any way to do such thing? if c++ can't, i wonder what programming language can do such large memory-needed task, if i open a very large image and save it back i also got the image data corrupted, but no problem for small one. anyone can give me advise?thanks all!
    Last edited by mr_empty; 12-07-2009 at 03:50 AM.

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    About GDI+

    Metafiles


    jpeg....Some information is lost in the compression process, but often the loss is imperceptible to the human eye.
    leaves the image blurry but not corrupt. as far as i know the images size is limited by only that of your system memory or storage space. break it down and make a separate file with the paint program 30000X42000 save it then load it with paint. then load that image with your prog to see if there is any corruption. if not then it is the save part of your prog that is the prob. what type of image bmp jpeg other.

    also 5000 x 5000 = 25 000 000
    30 000 x 42 000 = 1 260 000 000

    div them you get 50.4 i think it is the .4 that is the prob meow

  3. #3
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    3e4B*4.2e4B = 1.26GB, and that's for an 8bit monochrome image. if you're dealing with RGB24 or RGBA32, that's 3.78GB or 5.04GB of memory, respectively. Win32 just can't deal with that.

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    74
    Quote Originally Posted by sufoode View Post
    Have you considered porting your code to JavaScript?
    are u sure? javascript can handle it?

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,305
    Quote Originally Posted by mr_empty View Post
    are u sure? javascript can handle it?
    I think that person was poking fun at you.

    It's nothing to do with what programming language you are using. It can be done in C++ no matter how big the image files are, you just can't load it all into memory at once, which begs the question of why on earth would you want to combine them anyway if you can't actually view them once combined anyway?

    How about telling us what format the source and combined images files are or will be?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    iMalc, you can view images that large, just not on systems your familiar with.

    You will definitely want to use C++, and probably OpenGL, and want to definitely be familiar with GPU programming in general. You'll likely incorporate shaders to do a good amount of the work.

    You don't need to load all of it at once either, you can create larger groups of images by rendering multiple images to larger identically sized image segments in a stream-lined fashion. Then a final process could be implemented to do a stream-lined manipulation of identically sized images on the CPU by modifying the BITMAP formatting declarations to reassign coordinates to all of the pixels to the range of the final image size (stitching the files together) without requiring any video processing on this part.

    That's *roughly how I can imagine making this work in decent time on a generally high-end desktop PC with a stronger emphasis on video card, get a good one, especially if this is the kind of work you may do more frequently.

    You might be able to get around needing ridiculously large amounts of memory usage as well, focusing more on streams, segmenting read/writes, bunch of other cleverness, etc...
    Last edited by since; 12-09-2009 at 11:16 AM.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,305
    I know there will be applications that can open such large images because they're written to only hold part of it in RAM at once.

    I've taken this request to mean that he wasnt to combine images as a once-off task, meaning there would be no point buying anything to do it.
    Clearly we need more information.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    I just had to comment - how does one load up 4G movies to watch? They are not just loaded in to memory they are somewhat streamed and broken down into chunks to be worked on. If you have such a very large image, I take it very high quality and you need to view the whole picture then you must down grade the image, or pipe to some other source such as a printer which still breaks this down as any printer I know of does not contain very large memory to print a picture at one go. Perhaps consider threads of some sort of which each piece of code can act on a portion of your image file, then piece it all together to display from disk to screen.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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