Пример #1
0
/*
%F cdCreateCanvas para DBuffer.
O DC é um BITMAP em memoria.
*/
static void cdcreatecanvas(cdCanvas* canvas, void *data)
{
  int w, h;
  cdCanvas* canvas_dbuffer = (cdCanvas*)data;
  if (!canvas_dbuffer)
    return;

  cdCanvasActivate(canvas_dbuffer); /* Update size */
  w = canvas_dbuffer->w;
  h = canvas_dbuffer->h;
  if (w==0) w=1;
  if (h==0) h=1;

  Bitmap* bitmap = new Bitmap(w, h, PixelFormat24bppRGB);
  bitmap->SetResolution((REAL)(canvas_dbuffer->xres*25.4), (REAL)(canvas_dbuffer->yres*25.4));

  Graphics imggraphics(bitmap);
  imggraphics.Clear(Color::White);

  Graphics* graphics = new Graphics(bitmap);

  canvas->w = w;
  canvas->h = h;
  canvas->bpp = 24;

  /* Initialize base driver */
  cdCtxCanvas* ctxcanvas = cdwpCreateCanvas(canvas, graphics, CDW_BMP);

  ctxcanvas->bitmap = bitmap;
  ctxcanvas->canvas_dbuffer = canvas_dbuffer;
}
Пример #2
0
static void cdcreatecanvas(cdCanvas* canvas, void *data)
{
  int w, h;
  cdCanvas* canvas_dbuffer = (cdCanvas*)data;
  if (!canvas_dbuffer)
    return;

  cdCanvasActivate(canvas_dbuffer); /* Update size */
  w = canvas_dbuffer->w;
  h = canvas_dbuffer->h;
  if (w==0) w=1;
  if (h==0) h=1;

  Bitmap* bitmap = new Bitmap(w, h, PixelFormat24bppRGB);
  bitmap->SetResolution((REAL)(canvas_dbuffer->xres*25.4), (REAL)(canvas_dbuffer->yres*25.4));

  Graphics imggraphics(bitmap);
  imggraphics.Clear(Color((ARGB)Color::White));

  Graphics* graphics = new Graphics(bitmap);

  canvas->w = w;
  canvas->h = h;
  canvas->bpp = 24;

  /* Initialize base driver */
  cdCtxCanvas* ctxcanvas = cdwpCreateCanvas(canvas, graphics, CDW_BMP);

  ctxcanvas->bitmap = bitmap;
  ctxcanvas->canvas_dbuffer = canvas_dbuffer;

  {
    char* mode = cdCanvasGetAttribute(canvas_dbuffer, "UTF8MODE");
    int utf8mode = mode? (mode[0]=='1'? 1: 0): 0;
    if (utf8mode)
      cdCanvasSetAttribute(canvas, "UTF8MODE", "1");
  }
}