static void iColorbarUnMapMethod(Ihandle* ih) { if (ih->data->cddbuffer) cdKillCanvas(ih->data->cddbuffer); if (ih->data->cdcanvas) cdKillCanvas(ih->data->cdcanvas); }
void SimpleKillCanvas(void) { if (dbCanvas) { cdKillCanvas(dbCanvas); dbCanvas = NULL; } if (winCanvas) { cdKillCanvas(winCanvas); winCanvas = NULL; } }
static void iColorbarUnMapMethod(Ihandle* ih) { if (ih->data->cddbuffer) { cdKillCanvas(ih->data->cddbuffer); ih->data->cddbuffer = NULL; } if (ih->data->cdcanvas) { cdKillCanvas(ih->data->cdcanvas); ih->data->cdcanvas = NULL; } }
int main(int argc, char **argv) { Ihandle *dialog, *canvas; IupOpen(&argc, &argv); canvas = IupCanvas(NULL); IupSetAttribute(canvas, "RASTERSIZE", "300x200"); /* initial size */ IupSetAttribute(canvas, "SCROLLBAR", "YES"); IupSetAttribute(canvas, "XMAX", "599"); IupSetAttribute(canvas, "YMAX", "399"); IupSetCallback(canvas, "SCROLL_CB", (Icallback)scroll_cb); IupSetCallback(canvas, "RESIZE_CB", (Icallback)resize_cb); IupSetCallback(canvas, "ACTION", (Icallback)action); dialog = IupDialog(canvas); IupSetAttribute(dialog, "TITLE", "Scrollbar Test"); IupMap(dialog); cdcanvas = cdCreateCanvas(CD_IUP, canvas); IupSetAttribute(canvas, "RASTERSIZE", NULL); /* release the minimum limitation */ IupShowXY(dialog,IUP_CENTER,IUP_CENTER); IupMainLoop(); cdKillCanvas(cdcanvas); IupDestroy(dialog); IupClose(); return EXIT_SUCCESS; }
static void iMatrixUnMapMethod(Ihandle* ih) { if(ih->data->cddbuffer) { cdKillCanvas(ih->data->cddbuffer); ih->data->cddbuffer = NULL; } if(ih->data->cdcanvas) { cdKillCanvas(ih->data->cdcanvas); ih->data->cdcanvas = NULL; } iupMatrixMemRelease(ih); }
void main(void) { cdCanvas *canvas; canvas = cdCreateCanvas(CD_METAFILE,"TESTE.MF 100x100"); cdActivate(canvas); draw(); cdKillCanvas(canvas); }
static void iCellsUnMapMethod(Ihandle* ih) { if (ih->data->cd_canvas) { cdKillCanvas(ih->data->cd_canvas); ih->data->cd_canvas = NULL; } }
static int unmap_cb(Ihandle *ih) { cdCanvas *cdcanvas = (cdCanvas*)IupGetAttribute(ih, "_APP_CDCANVAS"); if (cdcanvas) cdKillCanvas(cdcanvas); return IUP_DEFAULT; }
void wdCanvasHardcopy(cdCanvas *canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy)) { /* Create a visualization surface. */ cdCanvas *canvas_copy = cdCreateCanvas(ctx, data); if (!canvas_copy) return; /* Do hardcopy. */ _wdHdcpyDoit(canvas, canvas_copy, draw_func); /* Destroy visualization surface. */ cdKillCanvas(canvas_copy); }
static int iColorBrowserDlgColorCnvUnMap_CB(Ihandle* ih) { IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA"); if (colordlg_data->cd_canvas_color) { cdKillCanvas(colordlg_data->cd_canvas_color); colordlg_data->cd_canvas_color = NULL; } return IUP_DEFAULT; }
void DrawCanvasDriver(cdContext* ctx, char* StrData) { cdCanvas* tmpCanvas = cdCreateCanvas(ctx, StrData); if (tmpCanvas == NULL) { printf("CreateCanvas(%s) - Failed!\n", StrData); return; } printf("CreateCanvas(%s)\n", StrData); SimpleDraw(tmpCanvas); cdKillCanvas(tmpCanvas); printf("KillCanvas()\n"); }
/** * IUP/CPI method for destroying an object */ static void cells_destroy(Ihandle *h) { /* Getting cell struct pointer saved in iup handle */ TCells* obj = (TCells*) iupGetEnv(h, "_IUPCELLS_DATA"); if (obj == NULL) return; /* Destroying cd canvases */ if (obj->cdcanvas != NULL) { cdKillCanvas(obj->cdcanvas); obj->cdcanvas = NULL; } if (obj->cddbuffer != NULL) { cdKillCanvas(obj->cddbuffer); obj->cddbuffer = NULL; } iupSetEnv(h, "_IUPCELLS_DATA", NULL); free(obj); }
static void drawTestCD(Ihandle* ih) { cdCanvas* canvas = cdCreateCanvas(CD_IUP, ih); int w = IupGetInt(ih, "PREVIEWWIDTH"); int h = IupGetInt(ih, "PREVIEWHEIGHT"); cdCanvasClear(canvas); cdCanvasForeground(canvas, cdEncodeColor(255, 0 , 0)); cdCanvasLine(canvas, 0, 0, w-1, h-1); cdCanvasLine(canvas, 0, h-1, w-1, 0); cdKillCanvas(canvas); }
static int cbDialogClose(Ihandle* iup_dialog) { cdCanvas* cd_canvas = (cdCanvas*)IupGetAttribute(iup_dialog, "cdCanvas"); imImage* image = (imImage*)IupGetAttribute(iup_dialog, "imImage"); if (cd_canvas) cdKillCanvas(cd_canvas); if (image) imImageDestroy(image); IupSetAttribute(iup_dialog, "cdCanvas", NULL); IupSetAttribute(iup_dialog, "imImage", NULL); return IUP_CLOSE; }
static void iTreeDestroyMethod(Ihandle* ih) { ItreeNodePtr temp, next; temp = ih->data->root; while(temp) { next = temp->next; if(temp->name) free(temp->name); free(temp); temp = next; } if(ih->data->cddbuffer) cdKillCanvas(ih->data->cddbuffer); if(ih->data->cdcanvas) cdKillCanvas(ih->data->cdcanvas); }
int SimpleDrawImageRGB(void) { use_opengl = 0; if (dbCanvas) cdKillCanvas(dbCanvas); if (contextplus) cdUseContextPlus(1); dbCanvas = cdCreateCanvas(CD_DBUFFERRGB, winCanvas); if (contextplus) cdUseContextPlus(0); curCanvas = dbCanvas; SimpleDraw(curCanvas); return 0; }
int item_print_action_cb(Ihandle* item_print) { Ihandle* canvas = IupGetDialogChild(item_print, "CANVAS"); unsigned int ri, gi, bi; imImage* image; char* title = IupGetAttribute(IupGetDialog(item_print), "TITLE"); Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG"); const char* background = IupConfigGetVariableStrDef(config, "MainWindow", "Background", "255 255 255"); cdCanvas* cd_canvas = cdCreateCanvasf(CD_PRINTER, "%s -d", title); if (!cd_canvas) return IUP_DEFAULT; /* draw the background */ sscanf(background, "%u %u %u", &ri, &gi, &bi); cdCanvasBackground(cd_canvas, cdEncodeColor((unsigned char)ri, (unsigned char)gi, (unsigned char)bi)); cdCanvasClear(cd_canvas); /* draw the image at the center of the canvas */ image = (imImage*)IupGetAttribute(canvas, "IMAGE"); if (image) { int x, y, canvas_width, canvas_height, view_width, view_height; double canvas_width_mm, canvas_height_mm; Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG"); int margin_width = IupConfigGetVariableIntDef(config, "Print", "MarginWidth", 20); int margin_height = IupConfigGetVariableIntDef(config, "Print", "MarginHeight", 20); cdCanvasGetSize(cd_canvas, &canvas_width, &canvas_height, &canvas_width_mm, &canvas_height_mm); /* convert to pixels */ margin_width = (int)((margin_width * canvas_width) / canvas_width_mm); margin_height = (int)((margin_height * canvas_height) / canvas_height_mm); view_fit_rect(canvas_width - 2 * margin_width, canvas_height - 2 * margin_height, image->width, image->height, &view_width, &view_height); x = (canvas_width - view_width) / 2; y = (canvas_height - view_height) / 2; imcdCanvasPutImage(cd_canvas, image, x, y, view_width, view_height, 0, 0, 0, 0); } cdKillCanvas(cd_canvas); return IUP_DEFAULT; }
//void SimpleDrawTest(cdCanvas* canvas) void SimpleDrawTestImageRGB(cdCanvas* canvas) { int size = 2048*2048; unsigned char *red, *green, *blue; cdCanvas* canvas = cdCreateCanvas(CD_IMAGERGB, "2048x2048"); cdActivate(canvas); red = calloc(size, 1); green = calloc(size, 1); blue = calloc(size, 1); cdPutImageRectRGB(2048, 2048, red, green, blue, 0, 3, 2048, 2017, 0, 2047, 3, 2020); free(red); free(green); free(blue); cdKillCanvas(canvas); }
void ColorbarTest(void) { Ihandle *dlg, *cb; IupControlsOpen(); /* Creates a canvas associated with the redraw action */ canvas = IupCanvas(NULL) ; IupSetCallback(canvas, "ACTION", (Icallback)redraw_cb); IupSetAttribute(canvas, "RASTERSIZE", "200x300"); cb = IupColorbar(); IupSetAttribute(cb, "RASTERSIZE", "70x"); IupSetAttribute(cb, "EXPAND", "VERTICAL"); IupSetAttribute(cb, "NUM_PARTS", "2"); IupSetAttribute(cb, "SHOW_SECONDARY", "YES"); IupSetAttribute(cb, "PREVIEW_SIZE", "60"); // IupSetAttribute(cb, "ACTIVE", "NO"); // IupSetAttribute(cb, "BGCOLOR", "128 0 255"); IupSetCallback(cb, "SELECT_CB", (Icallback)select_cb); IupSetCallback(cb, "CELL_CB", (Icallback)cell_cb); IupSetCallback(cb, "SWITCH_CB", (Icallback)switch_cb); IupSetCallback(cb, "EXTENDED_CB", (Icallback)extended_cb); dlg = IupDialog(IupHbox(canvas, cb, NULL)); IupSetAttribute(dlg, "MARGIN", "5x5"); IupSetAttribute(dlg, "TITLE", "IupColorbar"); /* Maps the dlg. This must be done before the creation of the CD canvas. Could also use MAP_CB callback. */ IupMap(dlg); cdcanvas = cdCreateCanvas(CD_IUP, canvas); IupPopup(dlg, IUP_CENTER, IUP_CENTER); cdKillCanvas(cdcanvas); }
int SimpleDrawGL(void) { char StrData[100]; int w, h; double w_mm, h_mm; if (use_opengl) return 0; cdCanvasGetSize(curCanvas, &w, &h, &w_mm, &h_mm); sprintf(StrData, "%dx%d %g", w, h, ((double)w/w_mm)); if (dbCanvas) cdKillCanvas(dbCanvas); dbCanvas = cdCreateCanvas(CD_GL, StrData); curCanvas = dbCanvas; use_opengl = 1; SimpleDraw(curCanvas); return 0; }
int canvas_unmap_cb(Ihandle* canvas) { cdCanvas* cd_canvas = (cdCanvas*)IupGetAttribute(canvas, "cdCanvas"); cdKillCanvas(cd_canvas); return IUP_DEFAULT; }
/************************************************************\ * Gera um plasma de todos os valores de h em um circulo. * \************************************************************/ void hls_hplasma(int iw, int ih, int cl, uchar *ur, uchar *ug, uchar *ub) { int i, j; float h; float fr, fg, fb; int r, g, b; long int os; int x, y; float x1, y1, x2, y2; int rd; int rs, rb; cdCanvas *rgb; char buf[200]; sprintf(buf, "%dx%d %p %p %p", iw, ih, ur, ug, ub); rgb = cdCreateCanvas(CD_IMAGERGB, buf); /* desenha o plasma */ os = 0; for (i = 0; i < ih; i++) { for (j = 0; j < iw; j++) { x = iw/2 - j; y = ih/2 - i; rd = sq(x) + sq(y); rb = sq(iw/2); rs = sq(iw/2 - cl); if ((rd < rb) && (rd > rs)) {; h = (float) (atan2(i - ih/2, j - iw/2) * pi_180); hls_hls2rgb(h, 0.5f, 1.0f, &fr, &fg, &fb); r = (int) (fr * 255.0f); g = (int) (fg * 255.0f); b = (int) (fb * 255.0f); ur[os + j] = touchar(r); ug[os + j] = touchar(g); ub[os + j] = touchar(b); } else { ur[os + j] = shade_r; ug[os + j] = shade_g; ub[os + j] = shade_b; } } os += iw; } /* desenha marcaccoes de 60 em 60 */ cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db)); x1 = 0.0f; y1 = ih/2.0f; x2 = 6.0f; y2 = ih/2.0f; cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2); rot(&x1, &y1, &x2, &y2, ih); cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb)); cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2); rot(&x1, &y1, &x2, &y2, ih); cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db)); cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2); rot(&x1, &y1, &x2, &y2, ih); cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb)); cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2); rot(&x1, &y1, &x2, &y2, ih); cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db)); cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2); rot(&x1, &y1, &x2, &y2, ih); cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2); /* desenha a borda */ cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db)); cdCanvasArc(rgb, iw/2, iw/2, iw, iw, 45.0, 225.0); cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb)); cdCanvasArc(rgb, iw/2, iw/2, iw, iw, 225.0, 45.0); cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb)); cdCanvasArc(rgb, iw/2, iw/2, iw-2*cl, iw-2*cl, 45.0, 225.0); cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db)); cdCanvasArc(rgb, iw/2, iw/2, iw-2*cl, iw-2*cl, 225.0, 45.0); cdKillCanvas(rgb); }