diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-11-24 02:46:19 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-11-24 02:46:19 +0000 |
| commit | 70abac1b8b995dc78ec312eb52f8724161b11b75 (patch) | |
| tree | 4bf4d24e190a2a49e98c8fe3fdbecabe8c9cd2fa /test/image.cxx | |
| parent | 4087b8cd9a139664420468c57489cae73c8b830a (diff) | |
Fix bugs in copy() methods.
Add Fl_Shared_Image class, with get() and release() methods.
Update Fl_Help_View to use Fl_Shared_Image class.
Update image demo to accept a filename, and to use the Fl_Shared_Image
class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1714 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/image.cxx')
| -rw-r--r-- | test/image.cxx | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/test/image.cxx b/test/image.cxx index fe70b73cd..31205eb00 100644 --- a/test/image.cxx +++ b/test/image.cxx @@ -1,5 +1,5 @@ // -// "$Id: image.cxx,v 1.6.2.3.2.3 2001/11/19 01:06:45 easysw Exp $" +// "$Id: image.cxx,v 1.6.2.3.2.4 2001/11/24 02:46:19 easysw Exp $" // // Fl_Image test program for the Fast Light Tool Kit (FLTK). // @@ -30,7 +30,7 @@ #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> -#include <FL/Fl_Image.H> +#include <FL/Fl_Shared_Image.H> #include <stdio.h> #include <stdlib.h> #include <math.h> @@ -96,13 +96,10 @@ int arg(int argc, char **argv, int &i) { } int main(int argc, char **argv) { + int i = 1; #ifndef WIN32 - int i = 1; - if (Fl::args(argc,argv,i,arg) < argc) { - fprintf(stderr," -v # : use visual\n%s\n",Fl::help); - exit(1); - } + Fl::args(argc,argv,i,arg); if (visid >= 0) { fl_open_display(); @@ -125,10 +122,23 @@ int main(int argc, char **argv) { Fl_Window window(400,400); ::w = &window; window.color(FL_WHITE); Fl_Button b(140,160,120,120,"Image w/Alpha"); ::b = &b; - make_image(); - Fl_RGB_Image *rgb = new Fl_RGB_Image(image, width, height,4); - Fl_RGB_Image *dergb; - dergb = (Fl_RGB_Image *)rgb->copy(); + + Fl_Image *rgb; + Fl_Image *dergb; + + if (argv[1]) { + rgb = Fl_Shared_Image::get(argv[1]); + if (rgb->w() > 100 || rgb->h() > 100) { + if (rgb->w() > rgb->h()) rgb = rgb->copy(100, 100 * rgb->h() / rgb->w()); + else rgb = rgb->copy(100 * rgb->w() / rgb->h(), 100); + } + b.label(argv[1]); + } else { + make_image(); + rgb = new Fl_RGB_Image(image, width, height,4); + } + + dergb = rgb->copy(); dergb->inactive(); b.image(rgb); @@ -155,5 +165,5 @@ int main(int argc, char **argv) { } // -// End of "$Id: image.cxx,v 1.6.2.3.2.3 2001/11/19 01:06:45 easysw Exp $". +// End of "$Id: image.cxx,v 1.6.2.3.2.4 2001/11/24 02:46:19 easysw Exp $". // |
