diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2009-04-12 13:48:03 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2009-04-12 13:48:03 +0000 |
| commit | afe1b90dd012216b007112dc5c92f22a1f034bd7 (patch) | |
| tree | 4901f175dfc467c1fad640657e9f0db4f823c8d4 /test/unittest_images.cxx | |
| parent | fcfe41ee0566038fcc6c690569b4d04469f43b06 (diff) | |
Reorganized Unittest / fixed and improved OS X keybord support and alternative input methods / fixed OS X utf8 DnD
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6755 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/unittest_images.cxx')
| -rw-r--r-- | test/unittest_images.cxx | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/test/unittest_images.cxx b/test/unittest_images.cxx new file mode 100644 index 000000000..161854af6 --- /dev/null +++ b/test/unittest_images.cxx @@ -0,0 +1,99 @@ +// +// "$Id: $" +// +// Unit tests for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2009 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 +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#include <FL/Fl_Box.H> +#include <FL/fl_draw.H> + +// +//------- test the line drawing capabilities of this implementation ---------- +// +class ImageTest : public Fl_Box { +public: + static Fl_Widget *create() { + int x, y; + uchar *dg, *dga, *drgb, *drgba; + dg = img_gray = (uchar*)malloc(128*128*1); + dga = img_gray_a = (uchar*)malloc(128*128*2); + drgb = img_rgb = (uchar*)malloc(128*128*3); + drgba = img_rgba = (uchar*)malloc(128*128*4); + for (y=0; y<128; y++) { + for (x=0; x<128; x++) { + *drgb++ = *drgba = *dg++ = *dga++ = y<<1; + *drgb++ = *drgba = x<<1; + *drgb++ = *drgba = (127-x)<<1; + *dga++ = *drgba = x+y; + } + } + return new ImageTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + } + static uchar *img_gray; + static uchar *img_gray_a; + static uchar *img_rgb; + static uchar *img_rgba; + ImageTest(int x, int y, int w, int h) : Fl_Box(x, y, w, h) { + label("Testing Image Drawing\n\n" + "This test renders four images, two of them with a checker board\n" + "visible through the graphics. Color and gray gradients should be\n" + "visible. This does not test any image formats such as JPEG."); + align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP); + box(FL_BORDER_BOX); + } + void draw() { + Fl_Box::draw(); + int xx = x()+10, yy = y()+10; + fl_color(FL_BLACK); fl_rect(xx, yy, 130, 130); + fl_draw_image(img_rgb, xx+1, yy+1, 128, 128, 3); + fl_draw("RGB", xx+134, yy+64); + xx = x()+10; yy = y()+10+134; + fl_color(FL_BLACK); fl_rectf(xx, yy, 130, 130); + fl_color(FL_WHITE); fl_rectf(xx+1, yy+1, 64, 64); + fl_color(FL_WHITE); fl_rectf(xx+65, yy+65, 64, 64); + fl_draw_image(img_rgba, xx+1, yy+1, 128, 128, 4); + fl_color(FL_BLACK); fl_draw("RGBA", xx+134, yy+64); + xx = x()+10+200; yy = y()+10; + fl_color(FL_BLACK); fl_rect(xx, yy, 130, 130); + fl_draw_image(img_gray, xx+1, yy+1, 128, 128, 1); + fl_draw("Gray", xx+134, yy+64); + xx = x()+10+200; yy = y()+10+134; + fl_color(FL_BLACK); fl_rectf(xx, yy, 130, 130); + fl_color(FL_WHITE); fl_rectf(xx+1, yy+1, 64, 64); + fl_color(FL_WHITE); fl_rectf(xx+65, yy+65, 64, 64); + fl_draw_image(img_gray_a, xx+1, yy+1, 128, 128, 2); + fl_color(FL_BLACK); fl_draw("Gray+Alpha", xx+134, yy+64); + } +}; + +uchar *ImageTest::img_gray = 0; +uchar *ImageTest::img_gray_a = 0; +uchar *ImageTest::img_rgb = 0; +uchar *ImageTest::img_rgba = 0; + +UnitTest images("drawing images", ImageTest::create); + +// +// End of "$Id: $" +// |
