mirror of
https://github.com/fltk/fltk.git
synced 2026-05-23 07:46:09 +08:00
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
This commit is contained in:
@@ -7,6 +7,7 @@ CHANGES IN FLTK 1.1.0b6
|
||||
notifications of various types.
|
||||
- Added new Fl_GIF_Image, Fl_PNG_Image, and
|
||||
Fl_JPEG_Image classes.
|
||||
- Added new Fl_Shared_Image class, a la FLTK 2.0.
|
||||
- Added new copy(), desaturate(), inactive(), and
|
||||
color_average() methods to the Fl_Image classes.
|
||||
- Fl_Float_Input and Fl_Int_Input no longer accept
|
||||
|
||||
+11
-38
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Help_View.H,v 1.1.2.3 2001/10/29 03:44:31 easysw Exp $"
|
||||
// "$Id: Fl_Help_View.H,v 1.1.2.4 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Help Viewer widget definitions.
|
||||
//
|
||||
@@ -24,18 +24,19 @@
|
||||
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||
//
|
||||
|
||||
#ifndef _Fl_Help_View_H_
|
||||
# define _Fl_Help_View_H_
|
||||
#ifndef Fl_Help_View_H
|
||||
# define Fl_Help_View_H
|
||||
|
||||
//
|
||||
// Include necessary header files...
|
||||
//
|
||||
|
||||
# include <stdio.h>
|
||||
# include <FL/Fl.H>
|
||||
# include <FL/Fl_Group.H>
|
||||
# include <FL/Fl_Scrollbar.H>
|
||||
# include <FL/fl_draw.H>
|
||||
# include "Fl.H"
|
||||
# include "Fl_Group.H"
|
||||
# include "Fl_Scrollbar.H"
|
||||
# include "fl_draw.H"
|
||||
# include "Fl_Shared_Image.H"
|
||||
|
||||
|
||||
//
|
||||
@@ -88,23 +89,6 @@ struct Fl_Help_Target
|
||||
int y; // Y offset of target
|
||||
};
|
||||
|
||||
//
|
||||
// Fl_Help_Image structure...
|
||||
//
|
||||
|
||||
class Fl_Image;
|
||||
|
||||
struct Fl_Help_Image
|
||||
{
|
||||
char *name, // Path and name of the image
|
||||
wattr[8], // Width attribute
|
||||
hattr[8]; // Height attribute
|
||||
Fl_Image *image; // FLTK image representation
|
||||
unsigned char *data; // Raw image data
|
||||
int copy; // Data is a copy?
|
||||
int w, h, d; // Image size & depth
|
||||
};
|
||||
|
||||
//
|
||||
// Fl_Help_View class...
|
||||
//
|
||||
@@ -145,18 +129,6 @@ class Fl_Help_View : public Fl_Group //// Help viewer widget
|
||||
size_; // Total document length
|
||||
Fl_Scrollbar scrollbar_; // Vertical scrollbar for document
|
||||
|
||||
int nimage_, // Number of images in a page
|
||||
aimage_; // Allocated blocks
|
||||
Fl_Help_Image *image_; // list of image descriptors
|
||||
|
||||
Fl_Help_Image *add_image(const char *name, const char *wattr,
|
||||
const char *hattr, int make = 1);
|
||||
Fl_Help_Image *find_image(const char *name, const char *wattr,
|
||||
const char *hattr);
|
||||
int load_gif(Fl_Help_Image *img, FILE *fp);
|
||||
int load_jpeg(Fl_Help_Image *img, FILE *fp);
|
||||
int load_png(Fl_Help_Image *img, FILE *fp);
|
||||
|
||||
Fl_Help_Block *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0);
|
||||
static int compare_blocks(const void *a, const void *b);
|
||||
void add_link(const char *n, int xx, int yy, int ww, int hh);
|
||||
@@ -169,6 +141,7 @@ class Fl_Help_View : public Fl_Group //// Help viewer widget
|
||||
int get_align(const char *p, int a);
|
||||
const char *get_attr(const char *p, const char *n, char *buf, int bufsize);
|
||||
Fl_Color get_color(const char *n, Fl_Color c);
|
||||
Fl_Shared_Image *get_image(const char *name, int W, int H);
|
||||
int handle(int);
|
||||
|
||||
void initfont(uchar &f, uchar &s) { nfonts_ = 0;
|
||||
@@ -207,8 +180,8 @@ class Fl_Help_View : public Fl_Group //// Help viewer widget
|
||||
const char *value() const { return (value_); }
|
||||
};
|
||||
|
||||
#endif // !_Fl_Help_View_H_
|
||||
#endif // !Fl_Help_View_H
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Help_View.H,v 1.1.2.3 2001/10/29 03:44:31 easysw Exp $".
|
||||
// End of "$Id: Fl_Help_View.H,v 1.1.2.4 2001/11/24 02:46:19 easysw Exp $".
|
||||
//
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Image.H,v 1.5.2.3.2.5 2001/11/23 12:06:35 easysw Exp $"
|
||||
// "$Id: Fl_Image.H,v 1.5.2.3.2.6 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@@ -74,7 +74,7 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image {
|
||||
Fl_Bitmask mask; // for internal use (mask bitmap)
|
||||
|
||||
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
|
||||
Fl_Image(W,H,D), array(bits), alloc_array(0), ld(LD), id(0) {data(&((char *)array), 1);}
|
||||
Fl_Image(W,H,D), array(bits), alloc_array(0), ld(LD), id(0), mask(0) {data(&((char *)array), 1);}
|
||||
virtual ~Fl_RGB_Image();
|
||||
virtual Fl_Image *copy(int W, int H);
|
||||
Fl_Image *copy() { return copy(w(), h()); }
|
||||
@@ -89,5 +89,5 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image {
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Image.H,v 1.5.2.3.2.5 2001/11/23 12:06:35 easysw Exp $".
|
||||
// End of "$Id: Fl_Image.H,v 1.5.2.3.2.6 2001/11/24 02:46:19 easysw Exp $".
|
||||
//
|
||||
|
||||
+40
-164
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// "$Id: Fl_Shared_Image.H,v 1.22 2001/07/16 19:38:17 robertk Exp $"
|
||||
// "$Id: Fl_Shared_Image.H,v 1.22.2.1 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Image file header file for the Fast Light Tool Kit (FLTK).
|
||||
// Shared image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-1999 by Bill Spitzak and others.
|
||||
// Copyright 1998-2001 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -20,184 +20,60 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
||||
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||
//
|
||||
|
||||
#ifndef Fl_Shared_Image_H
|
||||
#define Fl_Shared_Image_H
|
||||
# define Fl_Shared_Image_H
|
||||
|
||||
#include <FL/Fl_Image.H>
|
||||
#include <stddef.h>
|
||||
# include "Fl_Image.H"
|
||||
|
||||
struct FL_IMAGES_API Fl_Image_Type;
|
||||
|
||||
// Shared images class.
|
||||
class FL_IMAGES_API Fl_Shared_Image : public Fl_Image {
|
||||
protected:
|
||||
static const char* fl_shared_image_root;
|
||||
class Fl_Shared_Image : public Fl_Image {
|
||||
protected:
|
||||
|
||||
static int image_used;
|
||||
static size_t mem_usage_limit;
|
||||
static Fl_Shared_Image **images_; // Shared images
|
||||
static int num_images_; // Number of shared images
|
||||
static int alloc_images_; // Allocated shared images
|
||||
|
||||
static size_t mem_used;
|
||||
static int forbid_delete;
|
||||
const char *name_; // Name of image file
|
||||
int original_; // Original image?
|
||||
int refcount_; // Number of times this image has been used
|
||||
Fl_Image *image_; // The image that is shared
|
||||
int alloc_image_; // Was the image allocated?
|
||||
|
||||
Fl_Shared_Image* l1; // Left leaf in the binary tree
|
||||
Fl_Shared_Image* l2; // Right leaf in the binary tree
|
||||
const char* name; // Used to indentify the image, and as filename
|
||||
const uchar* datas; // If non zero, pointers on inlined compressed datas
|
||||
unsigned int used; // Last time used, for cache handling purpose
|
||||
int refcount; // Number of time this image has been get
|
||||
static int compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1);
|
||||
|
||||
Fl_Shared_Image() { }; // Constructor is private on purpose,
|
||||
// use the get function rather
|
||||
~Fl_Shared_Image();
|
||||
// Use get() and release() to load/delete images in memory...
|
||||
Fl_Shared_Image();
|
||||
Fl_Shared_Image(const char *n, Fl_Image *img = 0);
|
||||
virtual ~Fl_Shared_Image();
|
||||
void add();
|
||||
void update();
|
||||
|
||||
void find_less_used();
|
||||
static void check_mem_usage();
|
||||
public:
|
||||
|
||||
const char* get_filename();// Return the filename obtained from the concatenation
|
||||
// of the image root directory and this image name
|
||||
// WARNING : the returned pointer will be
|
||||
// available only until next call to get_filename
|
||||
|
||||
static const char* get_filename(const char*);
|
||||
|
||||
virtual void read() = 0;// decompress the image and create its pixmap
|
||||
|
||||
static void insert(Fl_Shared_Image*& p, Fl_Shared_Image* image);
|
||||
static Fl_Shared_Image* find(Fl_Shared_Image* image, const char* name);
|
||||
void remove_from_tree(Fl_Shared_Image*& p, Fl_Shared_Image* image);
|
||||
|
||||
|
||||
public:
|
||||
static Fl_Shared_Image *first_image;
|
||||
|
||||
// Return an Fl_Shared_Image, using the create function if an image with
|
||||
// the given name doesn't already exist. Use datas, or read from the
|
||||
// file with filename name if datas==0.
|
||||
static Fl_Shared_Image* get(Fl_Shared_Image* (*create)(),
|
||||
const char* name, const uchar* datas=0);
|
||||
|
||||
// Reload the image, useful if it has changed on disk, or if the datas
|
||||
// in memory have changed (you can also give a new pointer on datas)
|
||||
void reload(const uchar* datas=0);
|
||||
static void reload(const char* name, const uchar* datas=0);
|
||||
|
||||
// Remove an image from the database and delete it if its refcount has
|
||||
// fallen to zero
|
||||
// Each remove decrement the refcount, each get increment it
|
||||
// Return 1 if it has been really deleted.
|
||||
int remove();
|
||||
static int remove(const char* name);
|
||||
|
||||
// Clear the cache for this image and all of its children in the binary tree
|
||||
void clear_cache();
|
||||
|
||||
// Try to guess the filetype
|
||||
// Beware that calling this force you to link in all image types !
|
||||
static Fl_Image_Type* guess(const char* name, const uchar* datas=0);
|
||||
|
||||
// Set the position where images are looked for on disk
|
||||
static void set_root_directory(const char* d);
|
||||
|
||||
// Set the size of the cache (0 = unlimited is the default)
|
||||
static void set_cache_size(size_t l);
|
||||
const char *name() { return name_; }
|
||||
int refcount() { return refcount_; }
|
||||
void release();
|
||||
void reload();
|
||||
|
||||
virtual Fl_Image *copy(int W, int H);
|
||||
Fl_Image *copy() { return copy(w(), h()); }
|
||||
virtual void color_average(Fl_Color c, float i);
|
||||
virtual void desaturate();
|
||||
virtual void draw(int X, int Y, int W, int H, int cx, int cy);
|
||||
void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
|
||||
|
||||
static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0);
|
||||
static Fl_Shared_Image *get(const char *n, int W = 0, int H = 0);
|
||||
static Fl_Shared_Image **images() { return images_; }
|
||||
static int num_images() { return num_images_; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Description of a file format
|
||||
struct FL_IMAGES_API Fl_Image_Type {
|
||||
// Name of the filetype as it appear in the source code (uppercase)
|
||||
const char* name;
|
||||
// Function to test the filetype
|
||||
int (*test)(const uchar* datas, size_t size=0);
|
||||
// Function to get/create an image of this type
|
||||
Fl_Shared_Image* (*get)(const char* name, const uchar* datas=0);
|
||||
};
|
||||
extern FL_IMAGES_API Fl_Image_Type fl_image_filetypes[];
|
||||
|
||||
/* Specific image format functions. Add you own file format here. */
|
||||
|
||||
// PNG image class
|
||||
class FL_IMAGES_API Fl_PNG_Image : public Fl_Shared_Image {
|
||||
void read(); // Uncompress PNG datas
|
||||
Fl_PNG_Image() { }
|
||||
static Fl_Shared_Image* create() { return new Fl_PNG_Image; } // Instantiate
|
||||
public:
|
||||
// Check the given buffer if it is in PNG format
|
||||
static int test(const uchar* datas, size_t size=0);
|
||||
void measure(int& W, int& H); // Return width and heigth
|
||||
static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) {
|
||||
return Fl_Shared_Image::get(create, name, datas);
|
||||
}
|
||||
};
|
||||
|
||||
class FL_IMAGES_API Fl_GIF_Image : public Fl_Shared_Image {
|
||||
void read();
|
||||
Fl_GIF_Image() { }
|
||||
static Fl_Shared_Image* create() { return new Fl_GIF_Image; }
|
||||
public:
|
||||
static int test(const uchar* datas, size_t size=0);
|
||||
void measure(int& W, int& H);
|
||||
static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) {
|
||||
return Fl_Shared_Image::get(create, name, datas);
|
||||
}
|
||||
};
|
||||
|
||||
class FL_IMAGES_API Fl_XPM_Image : public Fl_Shared_Image {
|
||||
void read();
|
||||
Fl_XPM_Image() { }
|
||||
static Fl_Shared_Image* create() { return new Fl_XPM_Image; }
|
||||
public:
|
||||
static int test(const uchar* datas, size_t size=0);
|
||||
void measure(int& W, int& H);
|
||||
static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) {
|
||||
return Fl_Shared_Image::get(create, name, datas);
|
||||
}
|
||||
};
|
||||
|
||||
class FL_IMAGES_API Fl_BMP_Image : public Fl_Shared_Image {
|
||||
void read();
|
||||
Fl_BMP_Image() { }
|
||||
static Fl_Shared_Image* create() { return new Fl_BMP_Image; }
|
||||
public:
|
||||
static int test(const uchar* datas, size_t size=0);
|
||||
void measure(int& W, int& H);
|
||||
static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) {
|
||||
return Fl_Shared_Image::get(create, name, datas);
|
||||
}
|
||||
};
|
||||
|
||||
class FL_IMAGES_API Fl_JPEG_Image : public Fl_Shared_Image {
|
||||
void read();
|
||||
Fl_JPEG_Image() { }
|
||||
static Fl_Shared_Image* create() { return new Fl_JPEG_Image; }
|
||||
public:
|
||||
static int test(const uchar* datas, size_t size=0);
|
||||
void measure(int& W, int& H);
|
||||
static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) {
|
||||
return Fl_Shared_Image::get(create, name, datas);
|
||||
}
|
||||
};
|
||||
|
||||
//class FL_API Fl_Bitmap;
|
||||
class Fl_Bitmap;
|
||||
extern FL_IMAGES_API Fl_Bitmap nosuch_bitmap;
|
||||
|
||||
class FL_IMAGES_API Fl_UNKNOWN_Image {
|
||||
public:
|
||||
static int test(const uchar*, size_t =0) { return 1; };
|
||||
static Fl_Shared_Image* get(const char*, const uchar* = 0) {
|
||||
return (Fl_Shared_Image*) &nosuch_bitmap;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // !Fl_Shared_Image_H
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Shared_Image.H,v 1.22 2001/07/16 19:38:17 robertk Exp $"
|
||||
// End of "$Id: Fl_Shared_Image.H,v 1.22.2.1 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
|
||||
+13
-10
@@ -97,8 +97,9 @@ factory.o: ../FL/Fl_Browser.H ../FL/Fl_File_Icon.H ../FL/Fl_Counter.H
|
||||
factory.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/Fl_Text_Display.H
|
||||
factory.o: ../FL/fl_draw.H ../FL/Fl_Text_Buffer.H ../FL/Fl_Text_Editor.H
|
||||
factory.o: ../FL/Fl_Text_Display.H ../FL/Fl_Clock.H ../FL/Fl_Help_View.H
|
||||
factory.o: ../FL/Fl_Scrollbar.H ../FL/fl_draw.H ../FL/Fl_Progress.H
|
||||
factory.o: ../FL/Fl_Adjuster.H ../FL/Fl_Dial.H ../FL/Fl_Roller.H
|
||||
factory.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H
|
||||
factory.o: ../FL/Fl_Window.H ../FL/Fl_Progress.H ../FL/Fl_Adjuster.H
|
||||
factory.o: ../FL/Fl_Dial.H ../FL/Fl_Roller.H ../FL/Fl_Scrollbar.H
|
||||
factory.o: ../FL/Fl_Output.H ../FL/Fl_Value_Input.H ../FL/Fl_Input.H
|
||||
factory.o: ../FL/Fl_Value_Output.H ../FL/Fl_Value_Slider.H
|
||||
file.o: alignment_panel.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
@@ -112,14 +113,16 @@ file.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Button.H ../FL/Fl_Menu_Bar.H
|
||||
fluid.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
fluid.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/Fl_Group.H
|
||||
fluid.o: ../FL/Fl_Box.H ../FL/Fl_Button.H ../FL/Fl_File_Icon.H ../FL/Fl.H
|
||||
fluid.o: ../FL/Fl_Help_Dialog.H ../FL/Fl_Help_View.H ../FL/Fl_Group.H
|
||||
fluid.o: ../FL/Fl_Scrollbar.H ../FL/fl_draw.H ../FL/Fl_Hold_Browser.H
|
||||
fluid.o: ../FL/Fl_Browser.H ../FL/Fl_Menu_Bar.H ../FL/Fl_Menu_.H
|
||||
fluid.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/fl_ask.H
|
||||
fluid.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Window.H ../FL/Fl_File_Browser.H
|
||||
fluid.o: ../FL/Fl_File_Icon.H ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
|
||||
fluid.o: ../FL/Fl_Choice.H ../FL/fl_message.H ../FL/fl_ask.H ../FL/filename.H
|
||||
fluid.o: ../config.h about_panel.h Fl_Type.h ../FL/Fl_Widget.H
|
||||
fluid.o: ../FL/Fl_Help_Dialog.H ../FL/Fl_Help_View.H ../FL/Fl_Scrollbar.H
|
||||
fluid.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/fl_draw.H
|
||||
fluid.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H
|
||||
fluid.o: ../FL/Fl_Hold_Browser.H ../FL/Fl_Browser.H ../FL/Fl_Menu_Bar.H
|
||||
fluid.o: ../FL/Fl_Menu_.H ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/fl_ask.H
|
||||
fluid.o: ../FL/fl_draw.H ../FL/Fl_File_Chooser.H ../FL/Fl_Window.H
|
||||
fluid.o: ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H
|
||||
fluid.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H ../FL/Fl_Choice.H
|
||||
fluid.o: ../FL/fl_message.H ../FL/fl_ask.H ../FL/filename.H ../config.h
|
||||
fluid.o: about_panel.h ../FL/Fl_Group.H Fl_Type.h ../FL/Fl_Widget.H
|
||||
fluid.o: ../FL/Fl_Menu.H ../FL/Fl_Menu_Item.H Fluid_Image.h ../FL/Fl_Tabs.H
|
||||
fluid.o: ../FL/Fl_Pack.H ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H
|
||||
fluid.o: ../FL/Fl_Menu_Button.H
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.5 2001/11/23 12:06:36 easysw Exp $"
|
||||
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.6 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@@ -242,8 +242,8 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
|
||||
memset(new_array, 0, H * (W + 7) / 8);
|
||||
|
||||
// Scale the image using a nearest-neighbor algorithm...
|
||||
for (dy = h(), sy = 0, yerr = H / 2, new_ptr = new_array; dy > 0; dy --) {
|
||||
for (dx = w(), xerr = W / 2, old_ptr = array + sy * (w() + 7) / 8, sx = 0, new_bit = 128;
|
||||
for (dy = H, sy = 0, yerr = H / 2, new_ptr = new_array; dy > 0; dy --) {
|
||||
for (dx = W, xerr = W / 2, old_ptr = array + sy * (w() + 7) / 8, sx = 0, new_bit = 128;
|
||||
dx > 0;
|
||||
dx --) {
|
||||
old_bit = 128 >> (sx & 7);
|
||||
@@ -278,5 +278,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.5 2001/11/23 12:06:36 easysw Exp $".
|
||||
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.6 2001/11/24 02:46:19 easysw Exp $".
|
||||
//
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_GIF_Image.cxx,v 1.1.2.3 2001/11/22 15:35:01 easysw Exp $"
|
||||
// "$Id: Fl_GIF_Image.cxx,v 1.1.2.4 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Fl_GIF_Image routines.
|
||||
//
|
||||
@@ -353,8 +353,9 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
|
||||
|
||||
// split the image data into lines:
|
||||
for (i=0; i<Height; i++) {
|
||||
new_data[i+2] = new char[Width];
|
||||
new_data[i+2] = new char[Width+1];
|
||||
memcpy(new_data[i + 2], (char*)(Image + i*Width), Width);
|
||||
new_data[i + 2][Width] = 0;
|
||||
}
|
||||
|
||||
data(new_data, Height + 2);
|
||||
@@ -365,5 +366,5 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_GIF_Image.cxx,v 1.1.2.3 2001/11/22 15:35:01 easysw Exp $".
|
||||
// End of "$Id: Fl_GIF_Image.cxx,v 1.1.2.4 2001/11/24 02:46:19 easysw Exp $".
|
||||
//
|
||||
|
||||
+89
-1304
File diff suppressed because it is too large
Load Diff
+5
-4
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.7 2001/11/23 12:06:36 easysw Exp $"
|
||||
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.8 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Image drawing code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <FL/Fl_Image.H>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void fl_restore_clip(); // in fl_rect.cxx
|
||||
|
||||
Fl_Image::~Fl_Image() {
|
||||
@@ -100,8 +101,8 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
|
||||
new_image->alloc_array = 1;
|
||||
|
||||
// Scale the image using a nearest-neighbor algorithm...
|
||||
for (dy = h(), sy = 0, yerr = H / 2, new_ptr = new_array; dy > 0; dy --) {
|
||||
for (dx = w(), xerr = W / 2, old_ptr = array + sy * (w() * d() + ld);
|
||||
for (dy = H, sy = 0, yerr = H / 2, new_ptr = new_array; dy > 0; dy --) {
|
||||
for (dx = W, xerr = W / 2, old_ptr = array + sy * (w() * d() + ld);
|
||||
dx > 0;
|
||||
dx --) {
|
||||
for (c = 0; c < d(); c ++) *new_ptr++ = old_ptr[c];
|
||||
@@ -356,5 +357,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.7 2001/11/23 12:06:36 easysw Exp $".
|
||||
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.8 2001/11/24 02:46:19 easysw Exp $".
|
||||
//
|
||||
|
||||
+4
-9
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.8 2001/11/23 12:06:36 easysw Exp $"
|
||||
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.9 2001/11/24 02:46:19 easysw Exp $"
|
||||
//
|
||||
// Pixmap drawing code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@@ -245,17 +245,12 @@ Fl_Image *Fl_Pixmap::copy(int W, int H) {
|
||||
}
|
||||
}
|
||||
|
||||
// Copy image data...
|
||||
for (i = 0; i < h(); i ++, new_row ++) {
|
||||
*new_row = new char[chars_per_line];
|
||||
memcpy(*new_row, data()[i + ncolors + 1], chars_per_line);
|
||||
}
|
||||
// Scale the image using a nearest-neighbor algorithm...
|
||||
for (dy = h(), sy = 0, yerr = H / 2; dy > 0; dy --, new_row ++) {
|
||||
for (dy = H, sy = 0, yerr = H / 2; dy > 0; dy --, new_row ++) {
|
||||
*new_row = new char[chars_per_line];
|
||||
new_ptr = *new_row;
|
||||
|
||||
for (dx = w(), xerr = W / 2, old_ptr = data()[sy + ncolors + 1];
|
||||
for (dx = W, xerr = W / 2, old_ptr = data()[sy + ncolors + 1];
|
||||
dx > 0;
|
||||
dx --) {
|
||||
for (c = 0; c < chars_per_pixel; c ++) *new_ptr++ = old_ptr[c];
|
||||
@@ -467,5 +462,5 @@ void Fl_Pixmap::desaturate() {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.8 2001/11/23 12:06:36 easysw Exp $".
|
||||
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.9 2001/11/24 02:46:19 easysw Exp $".
|
||||
//
|
||||
|
||||
+323
-211
File diff suppressed because it is too large
Load Diff
+3
-2
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# "$Id: Makefile,v 1.18.2.14.2.18 2001/11/19 21:25:35 easysw Exp $"
|
||||
# "$Id: Makefile,v 1.18.2.14.2.19 2001/11/24 02:46:19 easysw Exp $"
|
||||
#
|
||||
# Library makefile for the Fast Light Tool Kit (FLTK).
|
||||
#
|
||||
@@ -76,6 +76,7 @@ CPPFILES = \
|
||||
Fl_Round_Button.cxx \
|
||||
Fl_Scroll.cxx \
|
||||
Fl_Scrollbar.cxx \
|
||||
Fl_Shared_Image.cxx \
|
||||
Fl_Single_Window.cxx \
|
||||
Fl_Slider.cxx \
|
||||
Fl_Tabs.cxx \
|
||||
@@ -279,5 +280,5 @@ uninstall:
|
||||
|
||||
|
||||
#
|
||||
# End of "$Id: Makefile,v 1.18.2.14.2.18 2001/11/19 21:25:35 easysw Exp $".
|
||||
# End of "$Id: Makefile,v 1.18.2.14.2.19 2001/11/24 02:46:19 easysw Exp $".
|
||||
#
|
||||
|
||||
+15
-9
@@ -90,23 +90,25 @@ Fl_File_Icon.o: ../FL/fl_draw.H ../FL/filename.H
|
||||
Fl_File_Icon2.o: ../config.h ../FL/Fl_File_Icon.H ../FL/Fl.H
|
||||
Fl_File_Icon2.o: ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Widget.H
|
||||
Fl_File_Icon2.o: ../FL/fl_draw.H ../FL/filename.H
|
||||
Fl_GIF_Image.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_GIF_Image.o: ../FL/Fl_GIF_Image.H ../FL/Fl_Pixmap.H ../FL/Fl_Image.H
|
||||
Fl_GIF_Image.o: ../FL/x.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_GIF_Image.o: ../FL/Fl_Window.H ../config.h
|
||||
Fl_GIF_Image.o: ../FL/x.H ../FL/Fl_Window.H ../config.h
|
||||
Fl_Group.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Group.o: ../FL/Fl_Group.H ../FL/Fl_Window.H ../FL/Fl_Group.H
|
||||
Fl_Group.o: ../FL/Fl_Widget.H ../FL/fl_draw.H ../FL/Fl_Tooltip.H
|
||||
Fl_Group.o: ../FL/Fl_Widget.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Help_Dialog.H ../FL/Fl.H ../FL/Enumerations.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Export.H ../FL/Fl_Double_Window.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Window.H ../FL/Fl_Help_View.H ../FL/Fl_Group.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Widget.H ../FL/fl_draw.H ../FL/Fl_Button.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Window.H ../FL/Fl_Help_View.H ../FL/Fl.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Scrollbar.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/fl_draw.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H
|
||||
Fl_Help_Dialog.o: ../FL/Fl_Button.H
|
||||
Fl_Help_View.o: ../FL/Fl_Help_View.H ../FL/Fl.H ../FL/Enumerations.H
|
||||
Fl_Help_View.o: ../FL/Fl_Export.H ../FL/Fl_Group.H ../FL/Fl_Scrollbar.H
|
||||
Fl_Help_View.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_Widget.H
|
||||
Fl_Help_View.o: ../FL/fl_draw.H ../config.h ../FL/Fl_Image.H ../FL/x.H
|
||||
Fl_Help_View.o: ../FL/Fl_Window.H ../FL/Fl_Pixmap.H ../FL/Fl_Image.H
|
||||
Fl_Help_View.o: ../FL/Fl_Export.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
|
||||
Fl_Help_View.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
|
||||
Fl_Help_View.o: ../FL/fl_draw.H ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H
|
||||
Fl_Help_View.o: ../FL/x.H ../FL/Fl_Window.H ../config.h
|
||||
Fl_Image.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/fl_draw.H
|
||||
Fl_Image.o: ../FL/x.H ../FL/Fl_Window.H ../FL/Fl_Widget.H
|
||||
Fl_Image.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Widget.H ../FL/Fl_Image.H ../FL/x.H
|
||||
@@ -182,6 +184,10 @@ Fl_Scroll.o: ../FL/fl_draw.H
|
||||
Fl_Scrollbar.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Scrollbar.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
|
||||
Fl_Scrollbar.o: ../FL/Fl_Widget.H ../FL/fl_draw.H
|
||||
Fl_Shared_Image.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Shared_Image.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H
|
||||
Fl_Shared_Image.o: ../FL/Fl_Window.H ../FL/Fl_GIF_Image.H ../FL/Fl_Pixmap.H
|
||||
Fl_Shared_Image.o: ../FL/Fl_JPEG_Image.H ../FL/Fl_PNG_Image.H
|
||||
Fl_Single_Window.o: ../FL/Fl_Single_Window.H ../FL/Fl_Window.H
|
||||
Fl_Slider.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Slider.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_Widget.H
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# "$Id: Makefile,v 1.19.2.7.2.10 2001/11/19 21:25:35 easysw Exp $"
|
||||
# "$Id: Makefile,v 1.19.2.7.2.11 2001/11/24 02:46:19 easysw Exp $"
|
||||
#
|
||||
# Test/example program makefile for the Fast Light Tool Kit (FLTK).
|
||||
#
|
||||
@@ -129,6 +129,9 @@ file_chooser$(EXEEXT): file_chooser.cxx
|
||||
help$(EXEEXT): help.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) help.cxx -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
|
||||
image$(EXEEXT): image.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) image.cxx -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
|
||||
keyboard$(EXEEXT): keyboard.cxx keyboard_ui.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) keyboard.cxx $(LINKFLTK) $(LDLIBS) -o $@
|
||||
@@ -189,5 +192,5 @@ uninstall:
|
||||
@echo Nothing to uninstall in test directory.
|
||||
|
||||
#
|
||||
# End of "$Id: Makefile,v 1.19.2.7.2.10 2001/11/19 21:25:35 easysw Exp $".
|
||||
# End of "$Id: Makefile,v 1.19.2.7.2.11 2001/11/24 02:46:19 easysw Exp $".
|
||||
#
|
||||
|
||||
+22
-12
@@ -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 $".
|
||||
//
|
||||
|
||||
+4
-3
@@ -161,14 +161,15 @@ hello.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Window.H
|
||||
hello.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Box.H
|
||||
help.o: ../FL/Fl_Help_Dialog.H ../FL/Fl.H ../FL/Enumerations.H
|
||||
help.o: ../FL/Fl_Export.H ../FL/Fl_Double_Window.H ../FL/Fl_Window.H
|
||||
help.o: ../FL/Fl_Help_View.H ../FL/Fl_Group.H ../FL/Fl_Scrollbar.H
|
||||
help.o: ../FL/Fl_Slider.H ../FL/fl_draw.H ../FL/Fl_Button.H
|
||||
help.o: ../FL/Fl_Help_View.H ../FL/Fl.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
|
||||
help.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/fl_draw.H
|
||||
help.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Button.H
|
||||
iconize.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
iconize.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
|
||||
iconize.o: ../FL/Fl_Button.H ../FL/Fl_Box.H
|
||||
image.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Window.H
|
||||
image.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Button.H
|
||||
image.o: ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Window.H
|
||||
image.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Window.H
|
||||
image.o: ../FL/Fl_Toggle_Button.H ../FL/Fl_Button.H ../FL/x.H
|
||||
image.o: list_visuals.cxx ../config.h
|
||||
input.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Window.H
|
||||
|
||||
Reference in New Issue
Block a user