There are many ways to implement a buffered image. I couldn't tell what's
the best way or why your code is not working. I don't know what type of
canvas is _CANVAS_PTR cd, for instance.
We can start by why "part of a drawn canvas"? Because by this code:
if (note->render != NULL) {
cdCanvasPutImageRect(cd, note->render, x, y, 0, 0, 0, 0);
return;
}
It seems that if render exists all your canvas will be used.
If you explain to me the logic of what you are trying to achieve, maybe we
can find a solution, because CD already interesting support for double
buffer drawing.
Best,
Scuri
Em seg., 30 de ago. de 2021 às 22:51, Isaac Raway <[email protected]> escreveu:
> I am trying to capture part of a drawn canvas to an image so I can save
> some expensive drawing operations.
>
> I try to do this with:
>
> void draw_note(_CANVAS_PTR cd, int viewMode, int active, tNOTE *note, int
> x, int y, int offsetX, int offsetY, tWIN *win, RECT clip_wh)
> {
> if (note->render != NULL) {
> cdCanvasPutImageRect(cd, note->render, x, y, 0, 0, 0, 0);
> return;
> }
>
> // --- drawing code removed ---
>
> note->render = cdCanvasCreateImage(cd, note->graphW, note->graphH);
> cdCanvasGetImage(cd, note->render, note->graphW, note->graphH);
> }
>
> The problem is that cdCanvasCreateImage always returns NULL, so the
> drawing results are not cached.
>
> My canvas is mapped like so:
>
> int graph_mapcb(Ihandle* self)
> {
> tWIN *win = (tWIN *)IupGetAttribute(self, "WIND");
>
> cdInitGdiPlus();
> cdUseContextPlus(1);
> if (self == win->notes_graph) {
> win->notes_cdReal = cdCreateCanvas(CD_NATIVEWINDOW,
> win->notes_graph);
> win->notes_cdGraph = win->notes_cdReal;//
> cdCreateCanvas(CD_DBUFFER, win->notes_cdReal); // was originally this
> } else if (self == win->daily_graph) {
> win->daily_cdReal = cdCreateCanvas(CD_NATIVEWINDOW,
> win->daily_graph);
> win->daily_cdGraph = win->daily_cdReal;//
> cdCreateCanvas(CD_DBUFFER, win->daily_cdReal); // was originally this
> }
> return (IUP_DEFAULT);
> }
>
> Any ideas why this isn't working?
> _______________________________________________
> Iup-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users