fixed blitting for uneven horizontal offsets/dests

pull/2/merge
HW 13 years ago
parent f307264fb6
commit b38b75298a

@ -182,19 +182,20 @@ static int blitToFrameBuffer(lua_State *L) {
*fbptr &= 0xF0;
*fbptr |= *bbptr & 0x0F;
fbptr += fb->finfo.line_length;
bbptr += (bb->w / 2);
}
} else {
for(y = 0; y < h; y++) {
*fbptr &= 0xF0;
*fbptr |= (*bbptr & 0xF0) >> 4;
*fbptr |= *bbptr >> 4;
fbptr += fb->finfo.line_length;
bbptr += (bb->w / 2);
}
}
xdest++;
xoffs++;
w--;
}
w = (w+1) / 2; // we'll always do two pixels at once for now
fbptr = (uint8_t*)(fb->data +
ydest * fb->finfo.line_length +
@ -205,15 +206,23 @@ static int blitToFrameBuffer(lua_State *L) {
if(xoffs & 1) {
for(y = 0; y < h; y++) {
for(x = 0; x < w; x++) {
fbptr[x] = (bbptr[x-1] << 4) | ((bbptr[x] & 0xF0) >> 4);
for(x = 0; x < (w / 2); x++) {
fbptr[x] = (bbptr[x] << 4) | (bbptr[x+1] >> 4);
}
if(w & 1) {
fbptr[x] &= 0x0F;
fbptr[x] |= bbptr[x] << 4;
}
fbptr += fb->finfo.line_length;
bbptr += (bb->w / 2);
}
} else {
for(y = 0; y < h; y++) {
memcpy(fbptr, bbptr, w);
memcpy(fbptr, bbptr, w / 2);
if(w & 1) {
fbptr[w/2 + 1] &= 0x0F;
fbptr[w/2 + 1] |= bbptr[w/2 + 1] << 4;
}
fbptr += fb->finfo.line_length;
bbptr += (bb->w / 2);
}

@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdio.h>
//#include <stdio.h>
#include <stdint.h>
#include <ft2build.h>
#include FT_FREETYPE_H

@ -33,6 +33,8 @@ function getglyph(face, facehash, charcode)
size = size,
g = glyph
}
else
glyphcache[hash].age = glyphcache_max_age
end
return glyphcache[hash].g
end
@ -48,6 +50,7 @@ function renderUtf8Text(x, y, face, facehash, text)
for uchar in string.gfind(text, "([%z\1-\127\194-\244][\128-\191]*)") do
local glyph = getglyph(face, facehash, util.utf8charcode(uchar))
fb:blitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight())
print(uchar, x + pen_x + glyph.l, y - glyph.t, glyph.bb:getWidth(), glyph.bb:getHeight())
pen_x = pen_x + glyph.ax
end
end

Loading…
Cancel
Save