Thread: What image format to use?

  1. #1
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065

    What image format to use?

    I have data that I need to display on a web site in a graphic format. It isn't a simple plot or I could use something like PLOTX. I have resinged myself to the fact that I will have to manually draw a graphic file. So many choices, however, for grapics these days. Which one should I use? The graphic will have about 6 colors (including black & white) and will be displayed via a web interface.

    Any suggestions would be appriciated.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    PNG, of course. You don't actually have that many choices on the web, and of those, JPEG is a different domain and GIF should be superseded by PNG.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Of course!!! Why didn't I think of that. . . oh yeah, I remember. . . it is because I HATE graphics and web design , but I like to play computer games. . . .is that an oxymoron?

    How Portable is Portable? And, how "easy" is it to generate the file? A brief look-through of the PNG website suggests that it is just a 2d array of ??int?? that one just paints. . . so does this mean that I would have to create an array, for example, of 800x600, then figure out all the math involved with plotting the points, then figure out the slope between each of these points, fill in all the points manually and go from there????? Or **takes deep breath** is there a set of functions within the libraries that allow me to ask for an 800x600 picture, then ask the lib to draw lines for me of specified pixel width and color?

    Please say option 2.

  4. #4
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I am not that experienced with graphics and this would probably be overkill but using something like SDL you can write text to the screen then read the screen in as an image... from there it is simple to save it as a bmp/tga/whatever just make it 24bit and you can get all the color info you need.

    Though there is probably a lot easy of a way.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You could look at the source for SDL_image, the library for the SDL that loads images. The PNG loader just uses libpng anyway, so you could have a look at that too.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    151
    SVG.
    Then you can use something like Batik to convert it to PNG if you want.
    System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.

    Useful resources:
    comp.lang.c FAQ | C++ FQA Lite

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    IrfanView ftw.

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by CornedBee
    PNG, of course. You don't actually have that many choices on the web, and of those, JPEG is a different domain and GIF should be superseded by PNG.
    There is still a question of compatibility. Internet Explorer has never been able to show PNG-s correctly. Even the brand new IE7 doesn't show them correctly. Since still most of the people use IE, it's better to use some image format that is supported by all browsers.

    What's wrong with JPEG? It IS the most popular one...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    The only real problem with PNGs and IE is transparency. In a graphic with 6 colours, that is not an issue.
    What problems does IE7 have with PNGs? I know for a fact that transparency is correctly supported.

    JPEG is lossy and always true-colour. Its compression algorithm introduces slight irregularities in everything. For clean strokes like diagrams or text, this is very detrimental - just look at a page of text scanned and then saved as JPEG. In filled areas, you can find slight colour variation. For 6 colours, the true-color is quite simply overkill. And because of the colour variation, it would become far more colours.
    The filled areas are especially noticeable in things like bar diagrams. It's simply not pretty if the bar is not filled solidly, but has slight variations all over the place.

    People often don't understand these shortcomings of JPEG. It was designed for real-life images, like photography. There, you don't really notice the side effects. For computer-generated graphics, GIF or PNG are far superior.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Make sure you use the pngout feature of Irfanview when you save the image. It will most likely reduce the size of the file by a good amount. If you don't have Irfanview, you can grab the command line program directly from http://www.advsys.net/ken/util/pngout.exe

  11. #11
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    What problems does IE7 have with PNGs? I know for a fact that transparency is correctly supported.
    My brother is a website designer. He likes PNGs but he couldn't use them, because IE7 didn't show the colors correctly (the PNG image and the background should've been the same colour, but IE7 showed PNG with strange colors).
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  12. #12
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    IrfanView appears to be a program that will take an existing image and convert it to something else - please correct me if I'm wrong.

    What I have, however, is a collection of data from a chromatogram that I'll need to display graphically.

    CornedBee -- I was actaully leaning towards JPEG, thanks for the warning. Will I have any issues with compatability using PNGs? The thing that concerns me about it is that some of the docs said that it wasn't fully supported in 2000. I know that there are at least two places that would use this system that are still using Windows 98. With that in mind, should I just generate GIFs?

  13. #13
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Just use the GIF, depending on the number of images you need the size difference of a GIF wont make enough of a difference to mater.

  14. #14
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    But JPEG isn't worse than GIF...
    You said six colors? Every image type can handle it.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  15. #15
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Quote Originally Posted by Wraithan
    Just use the GIF, depending on the number of images you need the size difference of a GIF wont make enough of a difference to mater.
    There are times when a GIF will be smaller than a PNG, but it does make a lot of difference if you get a lot of people to the site. Could mean a decent cut in bandwidth. And that's especially helpful if you've got a bad limit - like Geocities and their 1GB limit.

    You said six colors? Every image type can handle it.
    If I remember correctly, color JPEG images are always at 24-bit color. At least that's what it seems like when I save them in Irfanview and Paint.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Convert Pdf to Image format!
    By Dilmerv in forum C# Programming
    Replies: 4
    Last Post: 05-22-2006, 10:31 PM
  3. Reading text in an Image format
    By loko in forum C Programming
    Replies: 0
    Last Post: 09-29-2005, 06:38 PM
  4. image format
    By linuxdude in forum Game Programming
    Replies: 5
    Last Post: 08-09-2004, 09:31 AM
  5. Replies: 4
    Last Post: 03-02-2003, 09:12 AM