mirror of
https://github.com/pocketpy/pocketpy
synced 2025-12-08 19:20:17 +00:00
Update cute_png.c
This commit is contained in:
parent
871bc77bd3
commit
98bf9c0c81
@ -62,10 +62,7 @@ static bool cute_png_Image__new__(int argc, py_Ref argv) {
|
|||||||
PY_CHECK_ARG_TYPE(2, tp_int);
|
PY_CHECK_ARG_TYPE(2, tp_int);
|
||||||
int width = py_toint(py_arg(1));
|
int width = py_toint(py_arg(1));
|
||||||
int height = py_toint(py_arg(2));
|
int height = py_toint(py_arg(2));
|
||||||
cp_image_t* ud = py_newobject(py_retval(),
|
cp_image_t* ud = py_newobject(py_retval(), py_totype(argv), 0, sizeof(cp_image_t));
|
||||||
py_totype(argv),
|
|
||||||
py_gettype("cute_png", py_name("Image")),
|
|
||||||
sizeof(cp_image_t));
|
|
||||||
*ud = cp_load_blank(width, height);
|
*ud = cp_load_blank(width, height);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -77,10 +74,8 @@ static bool cute_png_Image__from_bytes_STATIC(int argc, py_Ref argv) {
|
|||||||
unsigned char* data = py_tobytes(argv, &size);
|
unsigned char* data = py_tobytes(argv, &size);
|
||||||
cp_image_t image = cp_load_png_mem(data, size);
|
cp_image_t image = cp_load_png_mem(data, size);
|
||||||
if(image.pix == NULL) return ValueError("cute_png: %s", cp_error_reason);
|
if(image.pix == NULL) return ValueError("cute_png: %s", cp_error_reason);
|
||||||
cp_image_t* ud = py_newobject(py_retval(),
|
cp_image_t* ud =
|
||||||
py_totype(argv),
|
py_newobject(py_retval(), py_gettype("cute_png", py_name("Image")), 0, sizeof(cp_image_t));
|
||||||
py_gettype("cute_png", py_name("Image")),
|
|
||||||
sizeof(cp_image_t));
|
|
||||||
*ud = image;
|
*ud = image;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -185,6 +180,7 @@ static bool cute_png_Image__to_png_bytes(int argc, py_Ref argv) {
|
|||||||
void pk__add_module_cute_png() {
|
void pk__add_module_cute_png() {
|
||||||
py_GlobalRef mod = py_newmodule("cute_png");
|
py_GlobalRef mod = py_newmodule("cute_png");
|
||||||
py_Type tp_image = py_newtype("Image", tp_object, mod, cute_png_Image__dtor);
|
py_Type tp_image = py_newtype("Image", tp_object, mod, cute_png_Image__dtor);
|
||||||
|
py_tpsetfinal(tp_image);
|
||||||
|
|
||||||
py_bindfunc(mod, "loads", cute_png_loads);
|
py_bindfunc(mod, "loads", cute_png_loads);
|
||||||
py_bindfunc(mod, "dumps", cute_png_dumps);
|
py_bindfunc(mod, "dumps", cute_png_dumps);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user