-
Notifications
You must be signed in to change notification settings - Fork 28
/
image_xpm_array.t
115 lines (93 loc) · 2.52 KB
/
image_xpm_array.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/perl -Iblib/lib -Iblib -Iblib/arch
#
use SDL;
use SDL::Config;
use SDL::Rect;
use SDL::Video;
use SDL::Image;
use SDL::Surface;
use Test::More;
use lib 't/lib';
use SDL::TestTool;
my $videodriver = $ENV{SDL_VIDEODRIVER};
$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
if( !SDL::TestTool->init(SDL_INIT_VIDEO))
{
plan( skip_all => 'Failed to init video' );
}
elsif( !SDL::Config->has('SDL_image') )
{
plan( skip_all => 'SDL_image support not compiled' );
}
my $screen_width = 800;
my $screen_height = 600;
SDL::init(SDL_INIT_VIDEO);
# setting video mode
my $screen = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_SWSURFACE);
#
#
my @test= (
'30 30 9 1',
' c #FFFFFF',
'. c #EFEFEF',
'+ c #CFCFCF',
'@ c #9F9F9F',
'# c #808080',
'$ c #505050',
'% c #202020',
'& c #000000',
'* c #303030',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' .+@##@+. ',
' .@$%&&%$@. ',
' .@*&&&&&&*@. ',
' +$&&&&&&&&$+ ',
' @%&&&&&&&&%@ ',
' #&&&&&&&&&&# ',
' #&&&&&&&&&&# ',
' @%&&&&&&&&%@ ',
' +$&&&&&&&&$+ ',
' .@*&&&&&&*@. ',
' .@$%&&%$@. ',
' .+@##@+. ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',);
my $mapped_color = SDL::Video::map_RGB($screen->format(), 43, 43, 255); #
SDL::Video::fill_rect( $screen,
SDL::Rect->new(0, 0,
$screen->w, $screen->h), $mapped_color);
my $picture = SDL::Image::read_XPM_from_array(\@test, 30);
warn SDL::get_error."\n" if(!$picture);
SKIP:
{
skip "picture not comming from XPM", 1 unless $picture;
SDL::Video::blit_surface( $picture, SDL::Rect->new(0, 0, $picture->w, $picture->h),
$screen, SDL::Rect->new(0, 0, $screen->w, $screen->h) );
SDL::Video::flip( $screen);
pass 'ok';
}
if($videodriver)
{
$ENV{SDL_VIDEODRIVER} = $videodriver;
}
else
{
delete $ENV{SDL_VIDEODRIVER};
}
sleep(1);
done_testing();