Skip to content

Commit

Permalink
fix blitbuffer to string of extra one byte copying
Browse files Browse the repository at this point in the history
  • Loading branch information
chrox committed May 30, 2014
1 parent d76b7a9 commit eb0bf54
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions ffi/blitbuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,43 @@ typedef struct ColorRGB32 {
} ColorRGB32;

typedef struct BlitBuffer4 {
int w;
int h;
int w;
int h;
int pitch;
uint8_t *data;
uint8_t config;
} BlitBuffer4;
typedef struct BlitBuffer8 {
int w;
int h;
int w;
int h;
int pitch;
Color8 *data;
uint8_t config;
} BlitBuffer8;
typedef struct BlitBuffer8A {
int w;
int h;
int w;
int h;
int pitch;
Color8A *data;
uint8_t config;
} BlitBuffer8A;
typedef struct BlitBufferRGB16 {
int w;
int h;
int w;
int h;
int pitch;
ColorRGB16 *data;
uint8_t config;
} BlitBufferRGB16;
typedef struct BlitBufferRGB24 {
int w;
int h;
int w;
int h;
int pitch;
ColorRGB24 *data;
uint8_t config;
} BlitBufferRGB24;
typedef struct BlitBufferRGB32 {
int w;
int h;
int w;
int h;
int pitch;
ColorRGB32 *data;
uint8_t config;
Expand Down Expand Up @@ -459,7 +459,7 @@ function BBRGB24_mt.__index:getBpp() return 24 end
function BBRGB32_mt.__index:getBpp() return 32 end
function BB_mt.__index:isRGB()
local bb_type = self:getType()
if bb_type == TYPE_BBRGB16
if bb_type == TYPE_BBRGB16
or bb_type == TYPE_BBRGB24
or bb_type == TYPE_BBRGB32 then
return true
Expand Down Expand Up @@ -504,7 +504,7 @@ end
function BB4_mt.__index:getPixelP(x, y)
--self:checkCoordinates(x, y)
local p = self.data + self.pitch*y + rshift(x, 1)
if band(x, 1) == 0 then
if band(x, 1) == 0 then
return ffi.cast(P_Color4U, p)
else
return ffi.cast(P_Color4L, p)
Expand Down Expand Up @@ -1114,7 +1114,7 @@ end

function BB.fromstring(width, height, buffertype, str, pitch)
local dataptr = ffi.C.malloc(#str)
ffi.copy(dataptr, str)
ffi.copy(dataptr, str, #str)
return BB.new(width, height, buffertype, dataptr, pitch)
end

Expand Down

0 comments on commit eb0bf54

Please sign in to comment.