Displaying in image file

This is a discussion on Displaying in image file within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I am interested in making a program to display an image in a window. I have tried using ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    128

    Displaying in image file

    Hi everyone,

    I am interested in making a program to display an image in a window. I have tried using a resource file before, but that method just compiled the image into the program, meaning that if I changed the image at all, the changes wouldn't be displayed in the program unless I re-compiled it. Does anyone know how I would get around this? How do I make a program read an image file from my hard disk every time it runs, so that if the image is changed, the changes will be visible when you run the program?

    Thanks.

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    128
    ...Failing that, is it possible to open an image using the Windows Picture and Fax viewer with C++?

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    It is possible to display an image on a window. Which library you use?
    It can be as simple as:
    Code:
    Window w = new Window();
    ...
    w.Background = new Image("C:\\Pictures\\Dumdum.jpeg");

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    128
    I am using the default Win32 with VC++ 2008. I also found out how to open the image with Picture and Faxt viewer, but your method sounds nicer

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,901
    Quote Originally Posted by C_ntua View Post
    It is possible to display an image on a window. Which library you use?
    It can be as simple as:
    Code:
    Window w = new Window();
    ...
    w.Background = new Image("C:\\Pictures\\Dumdum.jpeg");
    I think you are tainted with C#...

    Invariably, how you are going to do it will vary with what GUI library you use and possible what imagine library, if any, you use.
    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.

  6. #6
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by Elysia View Post
    I think you are tainted with C#...

    Invariably, how you are going to do it will vary with what GUI library you use and possible what imagine library, if any, you use.
    I said it "can be simple as..."
    If you are using a library I don't think it will be more complicated than that. There is usually an Image object of any kind. Similar, a Window object of any kind, or any kind of user interactive/non-interactive control will usually let you alter its background. If you combine those two you can view an image.

    In C# or in .NET in general the recommended would be to use an already built control for this, like a PictureBox. But my point is that you don't need an external program or a special control, since the functionality of altering a windows background image and the ability to have an already built in object for image are really basic.

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,901
    Like I said, you are tainted.
    It is rarely as easy as you describe. Not because it cannot be, but because there is rarely such quality written C++ code to be found in the first place. That's probably because people are ignorant.

    Furthermore, you use new when absolutely unnecessary and you try to assign to a non-pointer. Again, C# taint.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 01:44 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM

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