调整图片大小 - ReSize
函数简介
将图片缩放到指定的宽度和高度。
接口名称
ReSize
DLL调用
long ReSize(long ola, long image_ptr, int new_width, int new_height);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| image_ptr | 长整数型 | 要调整大小的图片句柄 |
| new_width | 整数型 | 目标宽度(像素) |
| new_height | 整数型 | 目标高度(像素) |
示例
long image = LoadImage(ola, "D:\\test\\source.png");
if (image != 0) {
int width, height;
GetImageSize(ola, image, &width, &height);
long small_image = ReSize(ola, image, width / 2, height / 2);
if (small_image != 0) {
SaveImageFromPtr(ola, small_image, "D:\\test\\small.png");
FreeImagePtr(ola, small_image);
}
FreeImagePtr(ola, image);
}
返回值
长整数型:成功返回新图片的句柄,失败返回0。
注意事项
- 调整后返回新的图片句柄,原图片不会被修改。
- 返回的图片需调用 FreeImagePtr 释放内存。
- 为保持图片比例,建议使用等比例缩放。
