add check to image blit
This commit is contained in:
parent
2fe4e825aa
commit
ebfa801560
|
@ -61,7 +61,6 @@ var sprite = {
|
||||||
this._p = p;
|
this._p = p;
|
||||||
this.del_anim?.();
|
this.del_anim?.();
|
||||||
this.texture = game.texture(p);
|
this.texture = game.texture(p);
|
||||||
say(p);
|
|
||||||
this.diffuse = this.texture;
|
this.diffuse = this.texture;
|
||||||
this.rect = [0,0,1,1];
|
this.rect = [0,0,1,1];
|
||||||
|
|
||||||
|
|
|
@ -2002,6 +2002,7 @@ JSC_GET(texture, delays, ints)
|
||||||
JSC_SCALL(texture_save, texture_save(js2texture(self), str));
|
JSC_SCALL(texture_save, texture_save(js2texture(self), str));
|
||||||
|
|
||||||
JSC_CCALL(texture_blit,
|
JSC_CCALL(texture_blit,
|
||||||
|
texture *tex = js2texture(self);
|
||||||
texture_blit(js2texture(self), js2texture(argv[0]), js2number(argv[1]), js2number(argv[2]), js2number(argv[3]), js2number(argv[4])))
|
texture_blit(js2texture(self), js2texture(argv[0]), js2number(argv[1]), js2number(argv[2]), js2number(argv[3]), js2number(argv[4])))
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_texture_funcs[] = {
|
static const JSCFunctionListEntry js_texture_funcs[] = {
|
||||||
|
@ -2009,8 +2010,8 @@ static const JSCFunctionListEntry js_texture_funcs[] = {
|
||||||
MIST_GET(texture, height),
|
MIST_GET(texture, height),
|
||||||
MIST_GET(texture, frames),
|
MIST_GET(texture, frames),
|
||||||
MIST_GET(texture, delays),
|
MIST_GET(texture, delays),
|
||||||
MIST_FUNC_DEF(texture, save, 2),
|
MIST_FUNC_DEF(texture, save, 1),
|
||||||
MIST_FUNC_DEF(texture, blit, 3)
|
MIST_FUNC_DEF(texture, blit, 5)
|
||||||
};
|
};
|
||||||
|
|
||||||
JSC_GETSET(font, linegap, number)
|
JSC_GETSET(font, linegap, number)
|
||||||
|
@ -2307,7 +2308,9 @@ JSC_SCALL(os_make_texture,
|
||||||
JS_SetPropertyStr(js, ret, "path", JS_DupValue(js,argv[0]));
|
JS_SetPropertyStr(js, ret, "path", JS_DupValue(js,argv[0]));
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(os_make_tex_data, ret = texture2js(texture_empty(js2number(argv[0]), js2number(argv[1]), js2number(argv[2]))))
|
JSC_CCALL(os_make_tex_data,
|
||||||
|
ret = texture2js(texture_empty(js2number(argv[0]), js2number(argv[1]), js2number(argv[2])))
|
||||||
|
)
|
||||||
|
|
||||||
JSC_CCALL(os_make_font,
|
JSC_CCALL(os_make_font,
|
||||||
font *f = MakeFont(js2str(argv[0]), js2number(argv[1]));
|
font *f = MakeFont(js2str(argv[0]), js2number(argv[1]));
|
||||||
|
|
|
@ -296,6 +296,8 @@ void texture_save(texture *tex, const char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
void blit_image(uint8_t* src, uint8_t* dest, int src_width, int src_height, int dest_width, int dest_height, int sx, int sy, int sw, int sh) {
|
void blit_image(uint8_t* src, uint8_t* dest, int src_width, int src_height, int dest_width, int dest_height, int sx, int sy, int sw, int sh) {
|
||||||
|
if (sx + sw > dest_width) return;
|
||||||
|
if (sy + sh > dest_height) return;
|
||||||
int src_stride = src_width * 4;
|
int src_stride = src_width * 4;
|
||||||
int dest_stride = dest_width * 4;
|
int dest_stride = dest_width * 4;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue