Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,172 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,918 people online right now. Registration is fast and FREE... Join Now!




Problem viewing image...

 
Reply to this topicStart new topic

Problem viewing image...

kiasta
6 Dec, 2007 - 12:24 PM
Post #1

New D.I.C Head
*

Joined: 18 Nov, 2007
Posts: 19


My Contributions
I am not sure if this is the right way to open a picture file, however it is the only way I could find that I understood. The code works without errors but it is not displaying the picture what am I doing wrong?

CODE
// Dogpile Icon
/*This program opens a file. It uses
fclose to close the file.*/


#include <stdio.h>
#include <iostream>

using namespace std;

FILE *stream;

int main( void )
{
    errno_t err;

    // Open for read (will fail if file "dogpile icon" does not exist)

    if( (err  = fopen_s( &stream, "INSERT IMAGE LOCATION", "r" )) !=0 )
        printf( "The file 'Dogpile Icon' was not opened\n" );
    else
        printf( "The file 'Dogpile Icon' was opened\n" );

    // Close stream if it is not NULL

    if( stream)
    {
        if ( fclose( stream ) )
        {
            printf( "The file 'Dogpile Icon' was not closed\n" );
        }
    }
    cout << "\n\n\n\n\n\n\n\n\n\n\n\npress enter...";
    cin.ignore(cin.rdbuf()->in_avail() +1);
}


What I'm ultimately trying to do is find a way to insert a picture as the title of the text based rpg I'm making (going to create in photoshop). If there is another way to display a picture please let me know, thank you.


User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Problem Viewing Image...
6 Dec, 2007 - 10:14 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
Well... no, this is not a very good way to load an image.

I know this is hard to hear, but based upon the code you have posted my best advice is to tell you to hit the books and learn more about programming in C++ before you try to program an RPG with graphics.

when I see a line of code like "INSERT IMAGE LOCATION" I wonder: Is that the file name that was in the program? When I see a file name like: "dogpile icon" I think the same thing.

I highly encourage programmers to push the limits of what they can do. I think every one who answers posts here would say the same, but you have to take little bites.

How about starting by just trying to open a text file and read in the contence. Then create a ASCII-art file (you can download lots of tools to convert images to ASCII-art) and load and display that on the screen.

Then try to create a simple text based RPG...

Then see if you can find a tutorial on a graphics library...

the code above is a LONG way from displaying a picture on the screen.
User is offlineProfile CardPM
+Quote Post

kiasta
RE: Problem Viewing Image...
7 Dec, 2007 - 08:49 AM
Post #3

New D.I.C Head
*

Joined: 18 Nov, 2007
Posts: 19


My Contributions
No I used the correct directory I just didn't want to put it on the code because there was no reason to. The name Dogpile Icon is just the name of the picture I'm just experimenting with. Well thanks for the advice it is a bit frustrating not knowing ho to do stuff though and all the books I have read have nothing on images and the MSDN library doesn't explain the funtions well enough for me to understand. But I guess I will just keep looking, thanks again.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 12:38AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month