Thread: Load jpg or bmp file to window

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    5

    Load jpg or bmp file to window

    Hello.
    I have picture file and i want to load it to win32 consol project.
    How can i do that without making a text file with 3 matrix of the RGB colors ?

    I dont want to use matrix file, because the picture is 700*700 pixels, and it takes something like 10-15 seconds to load it.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You can probably find some code to read a BMP or JPEG - in fact, there's something called libjpeg that does the latter.

    But I'm curious as to how you manage to consume 10-15 seconds on reading 700 x 700 x 3 byte matrix - my only guess is that you are doing that in some incredibly pessimal way. Perhaps if you post the code that you use for that, we can suggest something better.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    5
    Its taking so much time because i use glut library to read each point color, and then print that point on the screen...

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Surely you can use some OpenGL function to draw a bitmap directly?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    >> Surely you can use some OpenGL function to draw a bitmap directly?
    I've tried that, it's very slow. You have to use vertexs in ogl before it's worth using.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    That doesn't make sense. Rendering a static image onto a window is something that even the worst graphics card can do 1000+ times per second.
    (OK, so it's not that easy, but in theory, this is true.)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Maybe I was doing it wrong then, all I know is I was exploring ogl's capabilities, and found a function like glImage() or somthing like that, and it would draw an image like gdi would, with no 3d capabilities. And it was very slow.

  8. #8
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    CxImage is the best JPG converter ive found, much easier to use (IMO) than libjpeg and supports more formats.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM