Ejemplo n.º 1
0
static void cdcreatecanvas(cdCanvas* canvas, void* data)
{
  cdCtxCanvas* ctxcanvas;
  char* strdata = (char*)data;
  int w = 0, h = 0;
  double res = 0, xres, yres;
  FILE* fh;
  char filename[10240] = "";
  
  /* Inicializa parametros */
  if (strdata == NULL) 
    return;


  strdata += cdGetFileName(strdata, filename);
  if (filename[0] == 0)
    return;
  
  sscanf(strdata,"%dx%d %lg", &w, &h, &res); 
  if (w == 0 || h == 0)
    return;

  if (res)
  {
    xres = res;
    yres = res;
  }
  else
  {
    HDC ScreenDC = GetDC(NULL);
    xres = ((double)GetDeviceCaps(ScreenDC, LOGPIXELSX)) / 25.4;
    yres = ((double)GetDeviceCaps(ScreenDC, LOGPIXELSY)) / 25.4;
    ReleaseDC(NULL, ScreenDC);
  }
  
  /* Verifica se o arquivo pode ser aberto para escrita */
  fh = fopen(filename, "w");
  if (fh == 0)
    return;
  
  fclose(fh);
  
  /* Inicializa driver WIN32 */
  ctxcanvas = cdwCreateCanvas(canvas, NULL, CreateMetaFile(NULL), CDW_WMF);

  canvas->w = w;
  canvas->h = h;
  canvas->xres = xres;
  canvas->yres = yres;
  canvas->w_mm = ((double)w) / res;
  canvas->h_mm = ((double)h) / res;
  canvas->bpp = 24;
  ctxcanvas->clip_pnt[2].x = ctxcanvas->clip_pnt[1].x = canvas->w - 1;
  ctxcanvas->clip_pnt[3].y = ctxcanvas->clip_pnt[2].y = canvas->h - 1;
  
  /* Inicializacao de variaveis particulares para o WMF */
  ctxcanvas->filename = cdStrDup(filename);
}
Ejemplo n.º 2
0
static void primAddAttrib_Text(tPrimNode *prim, cdCanvas *canvas)
{
  prim->attrib.text.foreground = canvas->foreground; 

  prim->attrib.text.font_style = canvas->font_style;
  prim->attrib.text.font_size = canvas->font_size;
  prim->attrib.text.text_alignment = canvas->text_alignment; 
  prim->attrib.text.text_orientation = canvas->text_orientation;

  if (canvas->native_font[0])
  {
    prim->attrib_buffer = cdStrDup(canvas->native_font);
    prim->attrib.text.native_font = prim->attrib_buffer;
  }
  else
  {
    prim->attrib_buffer = cdStrDup(canvas->font_type_face);
    prim->attrib.text.font_type_face = prim->attrib_buffer;
  }
}