Michael Heiser wrote:
I resized the Box to 660x500 to be sure that it isn't a size problem
With the img size. I will check the FL_ALIGN_CLIP option.
If this doesn't work, probably I have to generate my own imgbox class or so.
I don't see any other solution.
Please see the attached working example program (I hope that
it will make its way to the news server).
It works with images smaller, equal, and bigger than the box
dimensions (you need 3 images: test1.jpg, .., test3.jpg).
Compile with
fltk-config --use-images --compile image.cxx
Have fun ;-)
Albrecht
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_JPEG_Image.H>
#include <FL/Fl.H>
#include <stdio.h>
#define MAX_IMAGES (3)
char *img_name[MAX_IMAGES] = { "test1.jpg", "test2.jpg", "test3.jpg" };
#define INTERVAL (3.0)
Fl_JPEG_Image *img [MAX_IMAGES] = {0};
Fl_Box *img_box = 0;
int img_index = 0;
void timer_cb(void *) {
img_box->image(img[img_index]);
img_box->redraw();
img_index++; // set next image index
if (img_index>=MAX_IMAGES) img_index = 0;
Fl::repeat_timeout(INTERVAL,timer_cb);
}
int main (int argc, char **argv) {
for (int i=0; i<MAX_IMAGES; i++) {
img[i] = new Fl_JPEG_Image(img_name[i]);
if (!img[i]->w()) {
printf("Failed to load image #%d: %s\n",i+1,img_name[i]);
return i+1;
}
}
Fl_Double_Window *win = new Fl_Double_Window(800,600);
img_box = new Fl_Box(50,50,640,480);
img_box->box(FL_THIN_DOWN_BOX);
img_box->color(FL_DARK1);
img_box->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
img_box->image(0); // no image at start
win->end();
win->show();
Fl::add_timeout(INTERVAL,timer_cb);
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk