summaryrefslogtreecommitdiff
path: root/src/win32/cdwimg.c
blob: 3fe912e0b7173a7c805cf338d687b3e006c33168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/** \file
 * \brief Windows Image Driver
 *
 * See Copyright Notice in cd.h
 */

#include <stdlib.h>
#include <stdio.h>

#include "cdwin.h"
#include "cdimage.h"



static void cdkillcanvas (cdCtxCanvas *ctxcanvas)
{
  cdwKillCanvas(ctxcanvas);
  
  memset(ctxcanvas, 0, sizeof(cdCtxCanvas));
  free(ctxcanvas);
}

/*
%F cdCreateCanvas para Image.
O DC é um BITMAP em memoria.
*/
static void cdcreatecanvas(cdCanvas* canvas, void *data)
{
  cdCtxCanvas* ctxcanvas;
  cdCtxImage* ctximage;
  
  if (data == NULL)
    return;

  ctximage = ((cdImage*)data)->ctximage;

  /* Inicializa parametros */
  if (ctximage == NULL) 
    return;
  
  /* Inicializa driver Image */
  ctxcanvas = cdwCreateCanvas(canvas, NULL, ctximage->hDC, CDW_BMP);

  canvas->w = ctximage->w;
  canvas->h = ctximage->h;
  canvas->w_mm = ctximage->w_mm;
  canvas->h_mm = ctximage->h_mm;
  canvas->bpp = ctximage->bpp;
  canvas->xres = ctximage->xres;
  canvas->yres = ctximage->yres;
  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;
}

static void cdinittable(cdCanvas* canvas)
{
  cdwInitTable(canvas);

  canvas->cxKillCanvas = cdkillcanvas;
}

static cdContext cdImageContext =
{
  CD_CAP_ALL & ~(CD_CAP_PLAY | CD_CAP_YAXIS | 
                 CD_CAP_FPRIMTIVES ),
  CD_CTX_IMAGE,
  cdcreatecanvas,  
  cdinittable,
  NULL,             
  NULL, 
};

cdContext* cdContextImage(void)
{
  if (cdUseContextPlus(CD_QUERY))
  {
    cdContext* ctx = cdGetContextPlus(CD_CTXPLUS_IMAGE);
    if (ctx != NULL)
      return ctx;
  }

  return &cdImageContext;
}