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

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

@ -33,6 +33,8 @@ function getglyph(face, facehash, charcode)
size = size, size = size,
g = glyph g = glyph
} }
else
glyphcache[hash].age = glyphcache_max_age
end end
return glyphcache[hash].g return glyphcache[hash].g
end 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 for uchar in string.gfind(text, "([%z\1-\127\194-\244][\128-\191]*)") do
local glyph = getglyph(face, facehash, util.utf8charcode(uchar)) 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()) 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 pen_x = pen_x + glyph.ax
end end
end end

Loading…
Cancel
Save