Thread: Loading images other than Bitmaps

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Loading images other than Bitmaps

    How would you do this and load it onto the client for editing and the sort? Thanks!

    Garfield
    1978 Silver Anniversary Corvette

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I guess one way is to look at the various encodings and work from there

    try here for file formats.

    I also imagine you would have little trouble finding some decoding/encoding libraries on the web if you spent some time searching

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    What sort of images? The GDI+ classes deal with BMP's,GIF's,JPEG's and TIFF's. Or there are quite a few third party libraries available.

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Originally posted by Sorensen
    What sort of images? The GDI+ classes deal with BMP's,GIF's,JPEG's and TIFF's. Or there are quite a few third party libraries available.
    What functions load these image files? Thanks!

    Garfield
    1978 Silver Anniversary Corvette

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    If you are using winxp then follow Sorensen's advice: gdi+ supports lots of image formats.

    If you are not using winxp or your target is different then take a look at OleLoadPicture (but NOT if you are using mingw (DevC) as the headers are incomplete). A simple search will yield a lot of examples of its use. You will need to #include <olectl.h> to use the fn.

    You may want to get up to speed on bitmap structures - I think Petzold discusses them in some detail. And Fordy's excellent link will give you lots of raw information to play with.

    Good luck.

  6. #6
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> You may want to get up to speed on bitmap structures <<

    Yeah, but these are just bitmaps. I need to load other image files too...

    Garfield
    1978 Silver Anniversary Corvette

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Garfield
    >> You may want to get up to speed on bitmap structures <<

    Yeah, but these are just bitmaps. I need to load other image files too...

    Garfield
    Yes but if you are manipulating that data, you will most probably do so in bitmap format

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Yeah, but these are just bitmaps. I need to load other image files too...

    Forgive me for not being explicit enough.

    Windows native image format is the bitmap: irrespective of the original file format, in order to render it as an image, windows must end up with a bitmap.

    BITMAPINFO,BITMAPINFOHEADER,BITMAPFILEHEADER etc etc are some of the structures that you should have a good idea about. As I said, Petzold discusses such things in detail.

    OleLoadPicture can be 'made' to 'convert' non-bmp image types such as jpeg to bitmaps for display etc BUT it requires manipulation of raw image data (not too much, but enough to make a wee bit more understanding of what's going on useful).

    A search for 'OleLoadPicture' will lead to some fascinating examples.

    Sorensen also mentioned 3rd party libs - and there are plenty of these. Not all come with source code, though, which may or may not be an issue for your project.

    I also didn't mention that you can get gdi+ dll and 'sdk' to run on win98/2k BUT the licensing restricts the use of the dll on these os's. This is probably ok for investigating what it's capable of ( a lot) but not really if you want to distribute - unless your target is winxp.

    Sorry for not being clearer on these points earlier.

    edit: correcting typos and (this is where I got it from, but ms may well have moved it):

    Go here to get GDI+ run-time dll - (it's called 'GDI+RTM'):

    http://www.microsoft.com/msdownload/...psdkredist.htm
    Last edited by Ken Fitlike; 02-02-2002 at 06:32 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    So I would use bitmap functions, etc. to work on all image files and loading/saving/manipulating them? Thanks!

    Garfield
    1978 Silver Anniversary Corvette

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>..So I would use bitmap functions, etc. to work on all image files and loading/saving/manipulating them?

    ..er..not exactly. You would load the image files and then code to convert them to bmps for viewing etc (unless you wanted to work on the raw data itself). You would have to save each image type according to its own specifications (ie convert from 'system' bmp to image type). Fordy's link above gives lots of raw info on various file types that should assist.

    BUT the licensing restricts the use of the dll on these os's
    I said this but on a quick re-read of the licence this is untrue: you can download, use, install etc the gdi+ dll. Probably best to read the licence yourself, just to make sure.

    Also: http://www.cplusplus.com has a GIFVIEW example in their source code section for viewing GIF images; it also is a great intro to use multiple threads within a c++ framework, specifically with static procedures.

    You may also be limited by copyright considerations. For instance, GIF format uses the LZW compression algorithm which is copyrighted; you are permitted to open or view GIF images but you have to pay a licence fee to save to GIF format. PNG is the open-source solution to this.

    So, after much waffling around the point it would appear that Sorensen's gdi+ may well be the quickest and easiest option, although it would do you no harm (and probably a lot of good) to learn the other stuff anyway.

    Good hunting and good luck!
    Last edited by Ken Fitlike; 02-02-2002 at 09:28 PM.

  11. #11
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> So, after much waffling around the point it would appear that Sorensen's gdi+ may well be the quickest and easiest option, although it would do you no harm (and probably a lot of good) to learn the other stuff anyway. <<

    Yes, but where do I learn about these GDI+ functions?
    1978 Silver Anniversary Corvette

  12. #12
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Good point. In the aug2001 psdk help: graphics & multimedia services/gdi+

  13. #13
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Originally posted by Ken Fitlike
    Good point. In the aug2001 psdk help: graphics & multimedia services/gdi+
    Ummm...what would this be?

    Garfield
    1978 Silver Anniversary Corvette

  14. #14
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Look here.

  15. #15
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    This article you gave me makes GDI+ look Win32 specific. Is this the only way to use image files (besides bitmaps)? Thanks!

    Garfield
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading Images in C
    By bucyyohare in forum C Programming
    Replies: 5
    Last Post: 02-28-2008, 05:52 PM
  2. Problem Loading Bitmaps in Allegro
    By LiNeAr in forum Game Programming
    Replies: 1
    Last Post: 08-15-2005, 04:12 PM
  3. Loading bitmaps with createfile() +CreateDIBSection
    By Stevo in forum Windows Programming
    Replies: 7
    Last Post: 05-13-2004, 09:22 PM
  4. Loading .jpg images from a file
    By Echidna in forum Windows Programming
    Replies: 4
    Last Post: 04-20-2002, 03:09 PM
  5. Loading Bitmaps
    By Neandrake in forum Windows Programming
    Replies: 4
    Last Post: 12-17-2001, 01:50 AM