1 /* Small program to test the features of vf_bmovl */
8 #include <SDL/SDL_image.h>
13 blit(int fifo
, unsigned char *bitmap
, int width
, int height
,
14 int xpos
, int ypos
, int alpha
, int clear
)
19 sprintf(str
, "RGBA32 %d %d %d %d %d %d\n",
20 width
, height
, xpos
, ypos
, alpha
, clear
);
22 if(DEBUG
) printf("Sending %s", str
);
24 write(fifo
, str
, strlen(str
));
25 nbytes
= write(fifo
, bitmap
, width
*height
*4);
27 if(DEBUG
) printf("Sent %d bytes of bitmap data...\n", nbytes
);
31 set_alpha(int fifo
, int width
, int height
, int xpos
, int ypos
, int alpha
) {
34 sprintf(str
, "ALPHA %d %d %d %d %d\n",
35 width
, height
, xpos
, ypos
, alpha
);
37 if(DEBUG
) printf("Sending %s", str
);
39 write(fifo
, str
, strlen(str
));
43 paint(unsigned char* bitmap
, int size
, int red
, int green
, int blue
, int alpha
) {
47 for(i
=0; i
< size
; i
+=4) {
55 int main(int argc
, char **argv
) {
58 int width
=0, height
=0;
59 unsigned char *bitmap
;
64 printf("Usage: %s <bmovl fifo> <image file> <width> <height>\n", argv
[0]);
65 printf("width and height are w/h of MPlayer's screen!\n");
69 width
= atoi(argv
[3]);
70 height
= atoi(argv
[4]);
72 fifo
= open( argv
[1], O_RDWR
);
74 fprintf(stderr
, "Error opening FIFO %s!\n", argv
[1]);
78 image
= IMG_Load(argv
[2]);
80 fprintf(stderr
, "Couldn't load image %s!\n", argv
[2]);
84 printf("Loaded image %s: width=%d, height=%d\n", argv
[2], image
->w
, image
->h
);
86 // Display and move image
87 for(i
=0; (i
< (width
- image
->w
)) && (i
< (height
- image
->h
)); i
+= 5)
88 blit(fifo
, image
->pixels
, image
->w
, image
->h
, i
, i
, 0, 1);
90 // Create a 75x75 bitmap
91 bitmap
= (unsigned char*)malloc(75*75*4);
93 // Paint bitmap red, 50% transparent and blit at position 50,50
94 paint(bitmap
, (75*75*4), 255, 0, 0, 128);
95 blit(fifo
, bitmap
, 75, 75, 50, 50, 0, 0);
97 // Paint bitmap green, 50% transparent and blit at position -50,50
98 paint(bitmap
, (75*75*4), 0, 255, 0, 128);
99 blit(fifo
, bitmap
, 75, 75, width
-50-75, 50, 0, 0);
101 // Paint bitmap blue, 50% transparent and blit at position -50,50
102 paint(bitmap
, (75*75*4), 0, 0, 255, 128);
103 blit(fifo
, bitmap
, 75, 75, 50, height
-50-75, 0, 0);
105 // Blit another image in the middle, completly transparent
106 blit(fifo
, image
->pixels
, image
->w
, image
->h
,
107 (width
/2)-(image
->w
/2), (height
/2)-(image
->h
/2), -255, 0);
110 for(i
=-255; i
<= 0; i
++)
111 set_alpha(fifo
, image
->w
, image
->h
,
112 (width
/2)-(image
->w
/2), (height
/2)-(image
->h
/2), i
);
117 SDL_FreeSurface(image
);