Sometimes, after modifying an annotation (e.g, changing its color), you may want to refresh the modified annotation only instead of refreshing the whole page in the rendering result.
In this scenario, you can do partial rendering: only render the area intersecting with the annotation's rectangle to the rendering result.
Following is a simple C++ example of how to refresh the area intersected with an ink annotation:
// Assume that a PDF page (with an ink annot) has been parsed.
// # Render the whole page to a bitmap.
int width = (int)page.GetWidth();
int height = (int)page.GetHeight();
Matrix matrix = page.GetDisplayMatrix(0, 0, width, height, e_Rotation0);
Bitmap render_bitmap(width, height, foxit::common::Bitmap::e_DIBArgb, NULL, 0);
// Fill the whole bitmap to white
render_bitmap.FillRect(0xFFFFFFFF, NULL);
Renderer render(render_bitmap, false);
render.StartRender(page, matrix, NULL);
// # Get the first annot and change its color to blue.
annots::Annot pdf_annot = page.GetAnnot(0);
pdf_annot.SetBorderColor(0x0000ff);
pdf_annot.ResetAppearanceStream();
// # Now, we need to do partial rendering -- only render the area intersected with annotation's rectangle.
// ## Get the rectangle (short as "rect") of annotation, in PDF coordinate.
RectF annot_rect = pdf_annot.GetRect();
// ## Transform annot's rect from PDF coordinate to device coordinate (here, rendered bitmap represents the device).
RectF annot_device_rect = annot_rect;
matrix.TransformRect(annot_device_rect);
RectI area_rect;
area_rect.left = annot_device_rect.left;
area_rect.top = annot_device_rect.top;
area_rect.right = annot_device_rect.right;
area_rect.bottom = annot_device_rect.bottom;
// ## Only fill part of the bitmap with white color, which equals to clear part of the bitmap to white.
render_bitmap.FillRect(0xFFFFFFFF, &area_rect);
// ## Do partial rendering: only render the cleared part again.
Renderer renderer_2(render_bitmap, false);
renderer_2.SetClipRect(&area_rect); // This is important.
renderer_2.StartRender(page, matrix, NULL);