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
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to