Subversion Repositories freemyipod

Rev

Rev 509 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 509 Rev 527
Line 23... Line 23...
23
 
23
 
24
#include "emcorelib.h"
24
#include "emcorelib.h"
25
#include "blend.h"
25
#include "blend.h"
26
 
26
 
27
 
27
 
28
void blend(int width, int height, int opacity,
28
void fill(int width, int height, uint32_t color,
29
           void* outbuf, int outx, int outy, int outstride,
29
          void* buf, int outx, int outy, int stride)
30
           void* in1buf, int in1x, int in1y, int in1stride,
-
 
31
           void* in2buf, int in2x, int in2y, int in2stride)
-
 
32
{
30
{
33
    char* in1 = (char*)in1buf + (in1x + in1y * in1stride) * 3;
31
    char* out = (char*)buf + (outx + outy * stride) * 3;
-
 
32
    int r = (color >> 0) & 0xff;
34
    char* in2 = (char*)in2buf + (in2x + in2y * in2stride) * 4;
33
    int g = (color >> 8) & 0xff;
35
    char* out = (char*)outbuf + (outx + outy * outstride) * 3;
34
    int b = (color >> 16) & 0xff;
36
    int x, y;
35
    int x, y;
37
    for (y = 0; y < height; y++)
36
    for (y = 0; y < height; y++)
38
    {
37
    {
39
        for (x = 0; x < width; x++)
38
        for (x = 0; x < width; x++)
40
        {
39
        {
41
            int r1 = *in1++;
40
            *out++ = r;
42
            int g1 = *in1++;
41
            *out++ = g;
43
            int b1 = *in1++;
-
 
44
            int r2 = *in2++;
-
 
45
            int g2 = *in2++;
-
 
46
            int b2 = *in2++;
42
            *out++ = b;
47
            int a = *in2++ * opacity;
-
 
48
            *out++ = (a * r2 + (65535 - a) * r1) >> 16;
-
 
49
            *out++ = (a * g2 + (65535 - a) * g1) >> 16;
-
 
50
            *out++ = (a * b2 + (65535 - a) * b1) >> 16;
-
 
51
        }
43
        }
52
        in1 += (in1stride - width) * 3;
44
        out += (stride - width) * 3;
-
 
45
    }
-
 
46
}
-
 
47
 
-
 
48
void blit(int width, int height, int pixelbytes,
-
 
49
          void* outbuf, int outx, int outy, int outstride,
-
 
50
          void* inbuf, int inx, int iny, int instride)
-
 
51
{
-
 
52
    int i;
-
 
53
    char* in = (char*)inbuf + (inx + iny * instride) * pixelbytes;
-
 
54
    char* out = (char*)outbuf + (outx + outy * outstride) * pixelbytes;
-
 
55
    int rowsize = width * pixelbytes;
-
 
56
    while (height--)
-
 
57
    {
-
 
58
        memcpy(out, in, rowsize);
53
        in2 += (in2stride - width) * 4;
59
        in += instride * pixelbytes;
54
        out += (outstride - width) * 3;
60
        out += outstride * pixelbytes;
55
    }
61
    }
56
}
62
}
57
 
63
 
58
void blendcolor(int width, int height, uint32_t color,
64
void blendcolor(int width, int height, uint32_t color,
59
                void* outbuf, int outx, int outy, int outstride,
65
                void* outbuf, int outx, int outy, int outstride,
Line 104... Line 110...
104
        in += (instride - width) * 4;
110
        in += (instride - width) * 4;
105
        out += (outstride - width) * 3;
111
        out += (outstride - width) * 3;
106
    }
112
    }
107
}
113
}
108
 
114
 
109
void blit(int width, int height, int pixelbytes,
115
void blend(int width, int height, int opacity,
110
          void* outbuf, int outx, int outy, int outstride,
116
           void* outbuf, int outx, int outy, int outstride,
-
 
117
           void* in1buf, int in1x, int in1y, int in1stride,
111
          void* inbuf, int inx, int iny, int instride)
118
           void* in2buf, int in2x, int in2y, int in2stride)
112
{
119
{
113
    int i;
120
    char* in1 = (char*)in1buf + (in1x + in1y * in1stride) * 3;
114
    char* in = (char*)inbuf + (inx + iny * instride) * pixelbytes;
121
    char* in2 = (char*)in2buf + (in2x + in2y * in2stride) * 3;
115
    char* out = (char*)outbuf + (outx + outy * outstride) * pixelbytes;
122
    char* out = (char*)outbuf + (outx + outy * outstride) * 3;
116
    int rowsize = width * pixelbytes;
123
    int x, y;
117
    while (height--)
124
    for (y = 0; y < height; y++)
118
    {
125
    {
-
 
126
        for (x = 0; x < width; x++)
-
 
127
        {
-
 
128
            int r1 = *in1++;
-
 
129
            int g1 = *in1++;
119
        memcpy(out, in, rowsize);
130
            int b1 = *in1++;
-
 
131
            int r2 = *in2++;
-
 
132
            int g2 = *in2++;
-
 
133
            int b2 = *in2++;
-
 
134
            *out++ = (opacity * r2 + (255 - opacity) * r1) >> 8;
-
 
135
            *out++ = (opacity * g2 + (255 - opacity) * g1) >> 8;
-
 
136
            *out++ = (opacity * b2 + (255 - opacity) * b1) >> 8;
-
 
137
        }
-
 
138
        in1 += (in1stride - width) * 3;
120
        in += instride * pixelbytes;
139
        in2 += (in2stride - width) * 3;
121
        out += outstride * pixelbytes;
140
        out += (outstride - width) * 3;
122
    }
141
    }
123
}
142
}
124
 
143
 
125
void fill(int width, int height, uint32_t color,
144
void blenda(int width, int height, int opacity,
126
          void* buf, int outx, int outy, int stride)
145
           void* outbuf, int outx, int outy, int outstride,
-
 
146
           void* in1buf, int in1x, int in1y, int in1stride,
-
 
147
           void* in2buf, int in2x, int in2y, int in2stride)
127
{
148
{
128
    char* out = (char*)buf + (outx + outy * stride) * 3;
149
    char* in1 = (char*)in1buf + (in1x + in1y * in1stride) * 3;
129
    int r = (color >> 0) & 0xff;
-
 
130
    int g = (color >> 8) & 0xff;
150
    char* in2 = (char*)in2buf + (in2x + in2y * in2stride) * 4;
131
    int b = (color >> 16) & 0xff;
151
    char* out = (char*)outbuf + (outx + outy * outstride) * 3;
132
    int x, y;
152
    int x, y;
133
    for (y = 0; y < height; y++)
153
    for (y = 0; y < height; y++)
134
    {
154
    {
135
        for (x = 0; x < width; x++)
155
        for (x = 0; x < width; x++)
136
        {
156
        {
137
            *out++ = r;
157
            int r1 = *in1++;
138
            *out++ = g;
158
            int g1 = *in1++;
-
 
159
            int b1 = *in1++;
-
 
160
            int r2 = *in2++;
-
 
161
            int g2 = *in2++;
139
            *out++ = b;
162
            int b2 = *in2++;
-
 
163
            int a = *in2++ * opacity;
-
 
164
            *out++ = (a * r2 + (65535 - a) * r1) >> 16;
-
 
165
            *out++ = (a * g2 + (65535 - a) * g1) >> 16;
-
 
166
            *out++ = (a * b2 + (65535 - a) * b1) >> 16;
140
        }
167
        }
-
 
168
        in1 += (in1stride - width) * 3;
-
 
169
        in2 += (in2stride - width) * 4;
141
        out += (stride - width) * 3;
170
        out += (outstride - width) * 3;
142
    }
171
    }
143
}
172
}