#!/usr/bin/env perl # # testgraphictool.pl # # Copyright (C) 2005 David J. Goehrig # # ------------------------------------------------------------------------------ # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # ------------------------------------------------------------------------------ # # Please feel free to send questions, suggestions or improvements to: # # David J. Goehrig # dgoehrig@cpan.org # use strict; use warnings; use MIME::Base64 qw(decode_base64); use SDL; use SDL::Surface; use SDL::App; use SDL::Tool::Graphic; my $app = new SDL::App(-title => "Graphic Tool Test", -width => 640, -height => 480, -depth => 16, -fullscreen => 0); my $app_rect = new SDL::Rect( -x=>0, -y=>0, -width=>$app->width, -height=>$app->height); write_spiral(); my $sprite = new SDL::Surface(-name => "/tmp/spiral.png"); $sprite->display_format(); #Test Zoom my $graphicTool = new SDL::Tool::Graphic(); $graphicTool->zoom($sprite, .5, .5, 1); my $sprite_rect = new SDL::Rect( -x=>0, -y=>0, -width=>$sprite->width, -height=>$sprite->height); $sprite->blit($sprite_rect, $app, $sprite_rect); $app->flip(); sleep 4; $app->fill($app_rect, $SDL::Color::black); #Test Rotate $graphicTool->rotoZoom($sprite, 90, 1, 1); $sprite_rect = new SDL::Rect( -x=>0, -y=>0, -width=>$sprite->width, -height=>$sprite->height); $sprite->blit($sprite_rect, $app, $sprite_rect); $app->flip(); sleep 4; +print "GrayScaling\n"; +$app->fill($app_rect, $SDL::Color::black); #Test GrayScale $graphicTool->grayScale($sprite); $sprite->blit($sprite_rect, $app, $sprite_rect); $app->flip(); sleep 4; sub write_spiral { my $png = decode_base64 < /tmp/spiral.png"; print FP $png; close FP; }