3.8 Image
Right PDF SDK provides APIs for image creation, conversion, input and output operations. Call ZSImage_LoadFromFile to load an image from a given path, and call ZSImage_Release to end the entire action. Here are some common APIs for image operations listed in Table 3.9. For a complete list of APIs, please refer to ZSImage.h.
Table 3.9
|
API Name |
Description |
1 |
ZSBitmap_Create |
Create a bitmap. |
2 |
ZSBitmap_ConvertFormat |
Convert a bitmap to another format. |
3 |
ZSImage_LoadFrame |
Load an image frame by index. |
4 |
ZSImage_GetCurrentFrameBitmap |
Retrieve the bitmap of the current frame. |
5 |
ZSImage_NumFrames |
Count frames of an image. |
6 |
ZSImage_LoadFrame |
Load an image frame by index. |
7 |
ZSImageFile_Create |
Create an image file. |
8 |
ZSImageFile_AddFrame |
Add a frame to image file. |
This is an example of using bitmap to flip an image.
Example: Load an image, get its size, and flip it using bitmap.
ZSImage image;
ZSImage_LoadFromFile(readFile, &image);
ZSImage_GetSize(image, &width, &height);
ZSBitmap srcBitmap, dstBitmap;
ZSImage_LoadFrame(image, 0);
ZSImage_GetCurrentFrameBitmap(image, &srcBitmap);
ZSBitmap_GetFlipped(srcBitmap, ZS_FALSE, ZS_TRUE, &dstBitmap);
ZSImageFile imageFile;
ZSImageFile_Create(writeFile, ZS_IMAGETYPE_PNG, 1, &imageFile);
ZSImageFile_AddFrame(imageFile, dstBitmap);
ZSImageFile_Release(imageFile);
ZSBitmap_Release(srcBitmap);
ZSBitmap_Release(dstBitmap);
ZSImage_Release(image);
|