hi
I was wondering, how do you insert a photo from file in your program?
hi
I was wondering, how do you insert a photo from file in your program?
I'd imagine you'd want to use a graphics API like DirectX or OpenGL to handle that.
Ubuntu Desktop
GCC/G++
Geany (for quick projects)
Anjuta (for larger things)
Perhaps also GD depending on what you want:
OpenGL - good for showing photos
SDL - Good for showing photos and custom manipulation, could mix with OpenGL: Tutorial
GD - I like using this for picture manipulation but not showing it
DevIL - I used it once, can't say much
Perhaps you mean to package the program with the image not being a seperate file but "embeded" into the code. That I don't know but is doable.
Displaying images is hard. Looking at your recent threads, you probably wouldn't be up to the task at the moment. I mean, you could try it if you wanted, but it would involve a lot of code. Here's a simple SDL program that displays an image.
I just typed that into the quick reply box, so there's no guarantee it will work. But you can see how complicated things can be with images . . . .Code:#include "SDL.h" int main(int argc, char *argv[]) { SDL_Surface *image; SDL_Event event; int quit = 0; if(SDL_Init(SDL_INIT_VIDEO) < 0) return 1; image = SDL_LoadBMP("file.bmp"); if(!image) return 1; if(!SDL_SetVideoMode(image->w, image->h, 0, SDL_SWSURFACE)) return 1; while(!quit) { SDL_BlitSurface(image, 0, SDL_GetVideoSurface(), 0); while(SDL_WaitEvent(&event)) { switch(event->type) { case SDL_QUIT: case SDL_KEYDOWN: quit = 1; } } } SDL_FreeSurface(image); return 0; }
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.
thanks for the replies. i didn't know it was that hard.
but i didn't need it that much anyway. I'll just learn more c++ before trying something like this.