GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Jul-2007, 01:22
montagne montagne is offline
New Member
 
Join Date: Jul 2007
Posts: 3
montagne is on a distinguished road

Display image on box or window


hey all,

i begin with fltk. i would like to know how to display two frames(images) in on window or in two box.
i am using fltk 2.
my code is :
CPP / C++ / C Code:
          
  //******************************************
            //fltk
            Window *window = new Window(700, 280);
            window->begin();
            Widget *boxG = new Widget(20, 40, 320, 240);
            boxG->box(UP_BOX);
            Widget *boxD = new Widget(350, 40, 320, 240);
            boxD->box(UP_BOX);
            rgbImage rgb("images/image000G.pnm"); 
 boxD->image(rgb);			
            window->end();
            window->show();
            //******************************************
the result is :
on window with two boxes and a small gray zone on the right box.
i tried to change the link to my frame (i used the real link) i have the same result.
thanks to all
  #2  
Old 27-Jul-2007, 04:17
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: display image on box or window


Quote:
Originally Posted by montagne
hey all,

i begin with fltk. i would like to know how to display two frames(images) in on window or in two box.
i am using fltk 2.

the result is :
on window with two boxes and a small gray zone on the right box.
i tried to change the link to my frame (i used the real link) i have the same result.
thanks to all

Hello and Welcome to GIDForums™ FLTK Forum montagne. Check out this thread and see if the information helps.

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #3  
Old 27-Jul-2007, 16:07
montagne montagne is offline
New Member
 
Join Date: Jul 2007
Posts: 3
montagne is on a distinguished road

Re: display image on box or window


Hi,
i saw the thread. i have done the same thing to resolve my problem with no succes.

so i explain the situation :
i have my code in FTLK directory
CPP / C++ / C Code:
//main.cpp

#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>
#include <fltk/rgbImage.h>
using namespace fltk;

int main(int argc, char **argv) {
//fltk
            Window *window = new Window(850, 500);
            window->begin();
            Widget *boxG = new Widget(20, 40, 400, 400);
            boxG->box(UP_BOX);
            Widget *boxD = new Widget(450, 40, 400, 400);
            boxD->box(UP_BOX);
            rgbImage rgb("logoINSA.png"); // test 1	
            //rgbImage rgb("../logoINSA.png"); // test 2
            //rgbImage rgb("./logoINSA.png"); // test 3
           //rgbImage rgb("/home/montagne/testFLTK/FLTK/logoINSA.png"); // test 4
           // rgbImage rgb("home/montagne/testFLTK/FLTK/logoINSA.png"); // test 5

 	  boxD->image(rgb);                      
            window->end();
            window->show();
  return run();
}
logoINSA.png frame and main.cpp are in the same directory(FLTK)
(the frame used can be seen at
CPP / C++ / C Code:
http://www.insa-rouen.fr/actualites/supportsdedition/logos-insa-de-rouen/logo-de-l-insa-de-rouen/logoINSA.png
I tried with test1 test2 ...... with no succes.a black ared in the center of the right box.

i use fltk2 and kubuntu
thanks all.
  #4  
Old 28-Jul-2007, 07:19
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Display image on box or window


I am a bit busy today so here it is without rhyme or reason.

Ask any questions or post comments and I'll get to them later.

CPP / C++ / C Code:
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>
#include <fltk/SharedImage.h>
#include <fltk/TiledImage.h>

using namespace fltk;

int main(int argc, char **argv)
{
  register_images();
  Window *window = new Window(850, 500);
  window->begin();
    Widget *boxG = new Widget(20, 40, 400, 400);
    boxG->box(UP_BOX);
    boxG->image(new TiledImage(SharedImage::get("logoINSA.png")));

    Widget *boxD = new Widget(450, 40, 400, 400);
    boxD->box(UP_BOX);
    boxD->image(SharedImage::get("logoINSA.png"));
  window->end();
  
  window->show();

  return run();
}


Mark

BTW, I usually use 1.1.x from subversion. 2.0 was a pain to compile with CygWin...
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #5  
Old 28-Jul-2007, 12:13
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Display image on box or window


Thats what happens when I try and rush something out. Here's a better attempt.

CPP / C++ / C Code:
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>
#include <fltk/SharedImage.h>
// #include <fltk/TiledImage.h>

using namespace fltk;

int main(int argc, char **argv)
{
  register_images();
  Window *window = new Window(850, 500);
  window->begin();
    Widget *boxG = new Widget(20, 40, 400, 400);
    boxG->box(UP_BOX);
//     boxG->image(new TiledImage(SharedImage::get("logoINSA.png")));
    boxG->image(SharedImage::get("logoINSA.png"));
    boxG->align(fltk::ALIGN_INSIDE);

    Widget *boxD = new Widget(450, 40, 400, 400);
    boxD->box(UP_BOX);
    boxD->image(SharedImage::get("logoINSA.png"));
    boxD->align(fltk::ALIGN_CLIP);

    window->resizable(boxG);
  window->end();
  
  window->show();

  return run();
}

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #6  
Old 16-Dec-2008, 10:05
awger awger is offline
New Member
 
Join Date: Dec 2008
Posts: 1
awger is on a distinguished road

Re: Display image on box or window


Sorry for the necro, but I was having similar problems and couldn't locate a definitive answer... this was the thread that kept coming up in my searches.

I'm new to FLTK, and I'm starting with 2.0. I like the high-speed, low-drag implementation so far, but it is quite different to what I'm accustomed to (VCL/CLX, Juce).

WRT displaying images in FLTK 2.0, I ran into two major issues:

#1 -- linker error (undefined reference to xpmImage::fetch), resolved by putting fltk2_images before fltk2 in library link order, and

#2 -- empty boxes when trying to display PNG images, resolved by adding libpng to the link (duh) and a call to fltk::register_images() at program start.

I resolved #1 through trial and error, and I'm not familiar enough with fltk to explain why rearranging link order fixed it (maybe an initialization dependency in fltk2? less likely, a problem with gcc 4.2.1?).

#2 was more frustrating, and it wasn't until I copied and pasted Mark's code and started dissecting that I stumbled across the call to register_images(), which was missing in my code (and in the OP's as well).

I have not been able to find this function documented anywhere (the official doxygen links to a missing page at the moment), and the only reference to it that I could find was in SharedImage::add_handler, which made it appear to be some internal thing. I did not bother to look in any of the v1 docs.

Payin' it forward...
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't display PNG deleted image in MHT Flavs83 Web Design Forum 0 17-Apr-2007 10:50
How to create or display an image Unit1 C Programming Language 1 27-Sep-2006 02:18
need help with a console menu system BullBuchanan C++ Forum 6 20-Aug-2006 14:46
GIM gidedit - a fltk fluid resize project cable_guy_67 FLTK Forum 2 01-Jun-2005 15:00
Checking source codes of image, audio and video files onauc C Programming Language 5 26-Feb-2005 21:47

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:37.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.