FireBirdLib - Topfield TMS PVR TAP Programming Library
TAP_Osd_PutFreeColorGd.c
Go to the documentation of this file.
1#include "libFireBird.h"
2
3int TAP_Osd_PutFreeColorGd(word rgn, int x, int y, TYPE_GrData *gd, bool sprite, dword FilterColor)
4{
6
7 int ret;
8 int R, G, B;
9 dword FR, FG, FB;
10 word TempRgn;
11 dword *PixelData = NULL;
12 register dword oy, cx, cy, p, P;
13
14 //Use a temporary memory region
15 TempRgn = TAP_Osd_Create_Chk("TAP_Osd_PutFreeColorGd", 0, 0, gd->width, gd->height, 0, OSD_Flag_MemRgn);
16
17 //Copy Gd data into OSD region
18 ret = TAP_Osd_PutGd_Chk("TAP_Osd_PutFreeColorGd A", TempRgn, 0, 0, gd, sprite);
19
20 //Save the OSD so we get a memory pointer to the pixel data
21 if(!ret) PixelData = (dword *) TAP_Osd_SaveBox_Chk("TAP_Osd_PutFreeColorGd A", TempRgn, 0, 0, gd->width, gd->height);
22
23 if(ret || !PixelData)
24 {
25 TAP_Osd_Delete(TempRgn);
26
27 TRACEEXIT();
28 return(ret ? ret : -1);
29 }
30
31 FR = (FilterColor >> 16) & 0xff;
32 FG = (FilterColor >> 8) & 0xff;
33 FB = FilterColor & 0xff;
34
35 //This routine manipulates the RGB data
36 for(oy = 0, cy = 0; cy < gd->height; cy++)
37 {
38 for(cx = 0; cx < gd->width; cx++)
39 {
40 //Calculate the pixel index out of the X/Y coordinates
41 p = cx + oy;
42
43 //Extract the colors and apply the filter function
44 P = PixelData[p];
45
46 //This algo subtracts the complementary color
47 //OSD_8888
48 B = (P & 0xff) - 255 + FB; if(B < 0) B = 0; if(B > 255) B = 255;
49 P >>= 8;
50 G = (P & 0xff) - 255 + FG; if(G < 0) G = 0; if(G > 255) G = 255;
51 P >>= 8;
52 R = (P & 0xff) - 255 + FR; if(R < 0) R = 0; if(R > 255) R = 255;
53 P >>= 8;
54 PixelData[p] = ARGB(P, R, G, B);
55 }
56
57 oy += gd->width;
58 }
59
60 //Restore the modified OSD
61 TAP_Osd_RestoreBox_Chk("TAP_Osd_PutFreeColorGd", TempRgn, 0, 0, gd->width, gd->height, PixelData);
62 TAP_Osd_Copy_Chk("TAP_Osd_PutFreeColorGd B", TempRgn, rgn, 0, 0, gd->width, gd->height, x, y, TRUE);
63 TAP_MemFree(PixelData);
64 TAP_Osd_Delete(TempRgn);
65
66 TRACEEXIT();
67 return 0;
68}
#define G(x, y, z)
Definition: Md5.c:116
int TAP_Osd_Copy_Chk(char *Comment, word srcRgnNum, word dstRgnNum, dword srcX, dword srcY, dword w, dword h, dword dstX, dword dstY, bool sprite)
int TAP_Osd_Create_Chk(char *Comment, dword x, dword y, dword w, dword h, byte lutIdx, int flag)
int TAP_Osd_PutFreeColorGd(word rgn, int x, int y, TYPE_GrData *gd, bool sprite, dword FilterColor)
int TAP_Osd_PutGd_Chk(char *Comment, word rgn, int x, int y, TYPE_GrData *gd, bool sprite)
void TAP_Osd_RestoreBox_Chk(char *Comment, word rgn, dword x, dword y, dword w, dword h, void *data)
byte * TAP_Osd_SaveBox_Chk(char *Comment, word rgn, dword x, dword y, dword w, dword h)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243