Skip to content

Commit

Permalink
Replaced "float" for "double" in several places.
Browse files Browse the repository at this point in the history
scanf use now %lg instead of %g
  • Loading branch information
scuri committed Aug 5, 2013
1 parent 29077c6 commit 23dcea2
Show file tree
Hide file tree
Showing 29 changed files with 162 additions and 157 deletions.
42 changes: 26 additions & 16 deletions html/en/drv/cgm.html
Expand Up @@ -56,28 +56,38 @@ <h4>Control&nbsp; </h4>
works with files created with text or binary coding. There are several callbacks for this driver. If one of the
callbacks returns a value different from zero, <font face="Courier">cdPlay</font>'s processing is interrupted. The
driver implements the callback <tt><strong><font face="Courier">CD_SIZECB</font> </strong></tt>and other callbacks
associated to CGM:<br>
<tt><font face="Courier"><strong>CD_COUNTERCB</strong></font> - int(*cdcgmcountercb)(cdContext *driver, double
percent) - </tt>Executed for each header of CGM commands; returns the percentage (0-100%) of headers read.<br>
<font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_SCLMDECB</span></strong></code></font><tt> - int(*cdcgmsclmdecb)(cdContext
*driver, short scl_mde, short *drw_mode, double *factor)</tt> <font face="Courier">-</font>
associated to CGM:<ul>
<li><tt><font face="Courier"><strong>CD_COUNTERCB</strong></font> - int(*cdcgmcountercb)(cdContext *driver, double
percent) - </tt>Executed for each header of CGM commands; returns the percentage (0-100%) of headers read.</li>
<li><font face="Times New Roman"><code><strong>
<span style="font-family: Courier">CD_SCLMDECB</span></strong></code></font><tt> - int(*cdcgmsclmdecb)(cdContext
*driver, short scl_mde, short *drw_mode, double *factor)</tt>
<font face="Courier">-</font>
Executed for the command CGM SCALE MODE. Returns the current CGM scale mode
and allows the callback to modify the scale mode used internally <font face="Courier">(ABSTRACT=0, METRIC=1)</font>.
and allows the callback to modify the scale mode used internally
<font face="Courier">(ABSTRACT=0, METRIC=1)</font>.
You can choose the
METRIC or ABSTRACT scale mode, but if the original scale mode is METRIC, then you must provide the conversion factor in mm per
pixel.<br>
<font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_VDCEXTCB</span></strong></code></font><tt> - int(*cdcgmvdcextcb)(cdContext
*driver, short type, void *first_x, void *first_y, void *second_x, void *second_y)</tt> <font face="Courier">-</font> Executed for the
CGM command CGM VDC EXTENT, returns the VDC SPACE. <br>
<font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_BEGPICTCB</span></strong></code></font><tt> - int(*cdcgmbegpictcb)(cdContext
pixel.</li>
<li><font face="Times New Roman"><code><strong>
<span style="font-family: Courier">CD_VDCEXTCB</span></strong></code></font><tt> - int(*cdcgmvdcextcb)(cdContext
*driver, short type, double *first_x, double *first_y, double *second_x,
double *second_y)</tt> <font face="Courier">-</font> Executed for the
CGM command CGM VDC EXTENT, returns the VDC SPACE. Currently type is always 1.</li>
<li><font face="Times New Roman"><code><strong>
<span style="font-family: Courier">CD_BEGPICTCB</span></strong></code></font><tt> - int(*cdcgmbegpictcb)(cdContext
*driver, char *pict)</tt> <font face="Courier">-</font> Executed for the command BEGIN PICTURE, returns the string
that describes the image.<br>
<font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_BEGPICTBCB</span></strong></code></font><tt> - int(*cdcgmbegpictbcb)(cdContext
*driver)</tt> <font face="Courier">-</font> Executed for the command BEGIN PICTURE BODY.<br>
<font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_CGMBEGMTFCB</span></strong></code></font> - <font face="Times New Roman"><code>
int (*cdcgmbegmtfcb)(cdContext *driver, int *xmin, int *ymin, int *xmax, int *ymax)</code></font> - Executed for the
that describes the image.</li>
<li><font face="Times New Roman"><code><strong>
<span style="font-family: Courier">CD_BEGPICTBCB</span></strong></code></font><tt> - int(*cdcgmbegpictbcb)(cdContext
*driver)</tt> <font face="Courier">-</font> Executed for the command BEGIN PICTURE BODY.</li>
<li><font face="Times New Roman"><code><strong>
<span style="font-family: Courier">CD_CGMBEGMTFCB</span></strong></code></font> -
<font face="Times New Roman"><code>int (*cdcgmbegmtfcb)(cdContext *driver, int *xmin, int *ymin, int *xmax, int *ymax)</code></font> - Executed for the
command BEGIN METAFILE, provides the drawing limits of the image in the file.
These are the same parameters passed to <strong>cdCanvasPlay</strong>.</li>
</ul>
</li>
</ul>
<h4>Coordinate System and Clipping</h4>
<ul>
Expand Down
8 changes: 4 additions & 4 deletions include/cd_private.h
Expand Up @@ -336,10 +336,10 @@ void cdgettextsizeEX(cdCtxCanvas* ctxcanvas, const char *s, int len, int *width,
/****************/
/* For Images */
/****************/
unsigned char cdZeroOrderInterpolation(int width, int height, const unsigned char *map, float xl, float yl);
unsigned char cdBilinearInterpolation(int width, int height, const unsigned char *map, float xl, float yl);
void cdImageRGBInitInverseTransform(int w, int h, int xmin, int xmax, int ymin, int ymax, float *xfactor, float *yfactor, const double* matrix, double* inv_matrix);
void cdImageRGBInverseTransform(int t_x, int t_y, float *i_x, float *i_y, float xfactor, float yfactor, int xmin, int ymin, int x, int y, double *inv_matrix);
unsigned char cdZeroOrderInterpolation(int width, int height, const unsigned char *map, double xl, double yl);
unsigned char cdBilinearInterpolation(int width, int height, const unsigned char *map, double xl, double yl);
void cdImageRGBInitInverseTransform(int w, int h, int xmin, int xmax, int ymin, int ymax, double *xfactor, double *yfactor, const double* matrix, double* inv_matrix);
void cdImageRGBInverseTransform(int t_x, int t_y, double *i_x, double *i_y, double xfactor, double yfactor, int xmin, int ymin, int x, int y, double *inv_matrix);
void cdImageRGBCalcDstLimits(cdCanvas* canvas, int x, int y, int w, int h, int *xmin, int *xmax, int *ymin, int *ymax, int* rect);
void cdRGB2Gray(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, long *color);

Expand Down
22 changes: 11 additions & 11 deletions src/cairo/cdcairo.c
Expand Up @@ -612,7 +612,7 @@ static void sSetTransform(cdCtxCanvas *ctxcanvas, const double* matrix)
/* rotation = translate to point + rotation + translate back */
/* the rotation must be corrected because of the Y axis orientation */
cairo_translate(ctxcanvas->cr, ctxcanvas->rotate_center_x, _cdInvertYAxis(ctxcanvas->canvas, ctxcanvas->rotate_center_y));
cairo_rotate(ctxcanvas->cr, (double)-ctxcanvas->rotate_angle * CD_DEG2RAD);
cairo_rotate(ctxcanvas->cr, -ctxcanvas->rotate_angle * CD_DEG2RAD);
cairo_translate(ctxcanvas->cr, -ctxcanvas->rotate_center_x, -_cdInvertYAxis(ctxcanvas->canvas, ctxcanvas->rotate_center_y));
}
}
Expand Down Expand Up @@ -1814,9 +1814,9 @@ static void set_rotate_attrib(cdCtxCanvas* ctxcanvas, char* data)

if (data)
{
sscanf(data, "%g %d %d", &ctxcanvas->rotate_angle,
&ctxcanvas->rotate_center_x,
&ctxcanvas->rotate_center_y);
sscanf(data, "%lg %d %d", &ctxcanvas->rotate_angle,
&ctxcanvas->rotate_center_x,
&ctxcanvas->rotate_center_y);
}
else
{
Expand All @@ -1835,9 +1835,9 @@ static char* get_rotate_attrib(cdCtxCanvas* ctxcanvas)
if (!ctxcanvas->rotate_angle)
return NULL;

sprintf(data, "%g %d %d", (double)ctxcanvas->rotate_angle,
ctxcanvas->rotate_center_x,
ctxcanvas->rotate_center_y);
sprintf(data, "%g %d %d", ctxcanvas->rotate_angle,
ctxcanvas->rotate_center_x,
ctxcanvas->rotate_center_y);

return data;
}
Expand Down Expand Up @@ -2025,11 +2025,11 @@ static void set_radialgradient_attrib(cdCtxCanvas* ctxcanvas, char* data)
if (data)
{
int cx1, cy1, cx2, cy2;
float rad1, rad2;
double rad1, rad2;
double offset;
int count = 1;

sscanf(data, "%d %d %g %d %d %g", &cx1, &cy1, &rad1, &cx2, &cy2, &rad2);
sscanf(data, "%d %d %lg %d %d %lg", &cx1, &cy1, &rad1, &cx2, &cy2, &rad2);

if (ctxcanvas->canvas->invert_yaxis)
{
Expand All @@ -2040,7 +2040,7 @@ static void set_radialgradient_attrib(cdCtxCanvas* ctxcanvas, char* data)
if (ctxcanvas->pattern)
cairo_pattern_destroy(ctxcanvas->pattern);

ctxcanvas->pattern = cairo_pattern_create_radial((double)cx1, (double)cx1, (double)rad1, (double)cx2, (double)cx2, (double)rad2);
ctxcanvas->pattern = cairo_pattern_create_radial((double)cx1, (double)cx1, rad1, (double)cx2, (double)cx2, rad2);
cairo_pattern_reference(ctxcanvas->pattern);

for(offset = 0.1; offset < 1.0; offset += 0.1)
Expand Down Expand Up @@ -2077,7 +2077,7 @@ static char* get_radialgradient_attrib(cdCtxCanvas* ctxcanvas)
if (cairo_pattern_get_radial_circles(ctxcanvas->pattern, &cx1, &cy1, &rad1, &cx2, &cy2, &rad2) == CAIRO_STATUS_SUCCESS)
{
static char data[100];
sprintf(data, "%d %d %g %d %d %g", (int)cx1, (int)cy1, (float)rad1, (int)cx2, (int)cy2, (float)rad2);
sprintf(data, "%d %d %g %d %d %g", (int)cx1, (int)cy1, rad1, (int)cx2, (int)cy2, rad2);
return data;
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/cairo/cdcairoctx.h
Expand Up @@ -45,7 +45,7 @@ struct _cdCtxCanvas

int img_format;

float rotate_angle;
double rotate_angle;
int rotate_center_x;
int rotate_center_y;

Expand Down
4 changes: 2 additions & 2 deletions src/cairo/cdcairoirgb.c
Expand Up @@ -65,7 +65,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data)
cdCtxCanvas* ctxcanvas;
cairo_surface_t *surface;
int w = 0, h = 0, use_alpha = 0;
float res = (float)3.78;
double res = 3.78;
unsigned char *rgb = NULL;
char* str_data = (char*)data;
char* res_ptr = NULL;
Expand All @@ -80,7 +80,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data)

res_ptr = strstr(str_data, "-r");
if (res_ptr)
sscanf(res_ptr+2, "%g", &res);
sscanf(res_ptr+2, "%lg", &res);

/* size and rgb */
#ifdef SunOS_OLD
Expand Down
4 changes: 2 additions & 2 deletions src/cairo/cdcaironative_win32.c
Expand Up @@ -83,8 +83,8 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data)

ScreenDC = GetDC(NULL);
canvas->bpp = GetDeviceCaps(ScreenDC, BITSPIXEL);
canvas->xres = (float)(((double)GetDeviceCaps(ScreenDC, LOGPIXELSX)) / 25.4);
canvas->yres = (float)(((double)GetDeviceCaps(ScreenDC, LOGPIXELSY)) / 25.4);
canvas->xres = (((double)GetDeviceCaps(ScreenDC, LOGPIXELSX)) / 25.4);
canvas->yres = (((double)GetDeviceCaps(ScreenDC, LOGPIXELSY)) / 25.4);
ReleaseDC(NULL, ScreenDC);

if (!data)
Expand Down
6 changes: 3 additions & 3 deletions src/cairo/cdcairopdf.c
Expand Up @@ -42,7 +42,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data)

if (*strdata != '\0')
{
float num;
double num;
strdata++;
switch (*strdata++)
{
Expand All @@ -54,11 +54,11 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data)
break;
}
case 'w':
sscanf(strdata, "%g", &num);
sscanf(strdata, "%lg", &num);
w_pt = CD_MM2PT*num;
break;
case 'h':
sscanf(strdata, "%g", &num);
sscanf(strdata, "%lg", &num);
h_pt = CD_MM2PT*num;
break;
case 'o':
Expand Down
6 changes: 3 additions & 3 deletions src/cairo/cdcairops.c
Expand Up @@ -65,7 +65,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data)

if (*strdata != '\0')
{
float num;
double num;
strdata++;
switch (*strdata++)
{
Expand All @@ -77,11 +77,11 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data)
break;
}
case 'w':
sscanf(strdata, "%g", &num);
sscanf(strdata, "%lg", &num);
w_pt = CD_MM2PT*num;
break;
case 'h':
sscanf(strdata, "%g", &num);
sscanf(strdata, "%lg", &num);
h_pt = CD_MM2PT*num;
break;
case 'e':
Expand Down
30 changes: 15 additions & 15 deletions src/cd_image.c
Expand Up @@ -302,20 +302,20 @@ void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax
canvas->cxScrollArea(canvas->ctxcanvas, xmin, xmax, ymin, ymax, dx, dy);
}

unsigned char cdZeroOrderInterpolation(int width, int height, const unsigned char *map, float xl, float yl)
unsigned char cdZeroOrderInterpolation(int width, int height, const unsigned char *map, double xl, double yl)
{
int x0 = (int)(xl-0.5f);
int y0 = (int)(yl-0.5f);
int x0 = (int)(xl-0.5);
int y0 = (int)(yl-0.5);
x0 = x0<0? 0: x0>width-1? width-1: x0;
y0 = y0<0? 0: y0>height-1? height-1: y0;
return map[y0*width + x0];
}

unsigned char cdBilinearInterpolation(int width, int height, const unsigned char *map, float xl, float yl)
unsigned char cdBilinearInterpolation(int width, int height, const unsigned char *map, double xl, double yl)
{
unsigned char fll, fhl, flh, fhh;
int x0, y0, x1, y1;
float t, u;
double t, u;

if (xl < 0.5)
{
Expand All @@ -329,9 +329,9 @@ unsigned char cdBilinearInterpolation(int width, int height, const unsigned char
}
else
{
x0 = (int)(xl-0.5f);
x0 = (int)(xl-0.5);
x1 = x0+1;
t = xl - (x0+0.5f);
t = xl - (x0+0.5);
}

if (yl < 0.5)
Expand All @@ -346,9 +346,9 @@ unsigned char cdBilinearInterpolation(int width, int height, const unsigned char
}
else
{
y0 = (int)(yl-0.5f);
y0 = (int)(yl-0.5);
y1 = y0+1;
u = yl - (y0+0.5f);
u = yl - (y0+0.5);
}

fll = map[y0*width + x0];
Expand All @@ -362,19 +362,19 @@ unsigned char cdBilinearInterpolation(int width, int height, const unsigned char
fll);
}

void cdImageRGBInitInverseTransform(int w, int h, int xmin, int xmax, int ymin, int ymax, float *xfactor, float *yfactor, const double* matrix, double* inv_matrix)
void cdImageRGBInitInverseTransform(int w, int h, int xmin, int xmax, int ymin, int ymax, double *xfactor, double *yfactor, const double* matrix, double* inv_matrix)
{
*xfactor = (float)(xmax-xmin)/(float)(w-1);
*yfactor = (float)(ymax-ymin)/(float)(h-1);
*xfactor = (double)(xmax-xmin)/(double)(w-1);
*yfactor = (double)(ymax-ymin)/(double)(h-1);
cdMatrixInverse(matrix, inv_matrix);
}

void cdImageRGBInverseTransform(int t_x, int t_y, float *i_x, float *i_y, float xfactor, float yfactor, int xmin, int ymin, int x, int y, double *inv_matrix)
void cdImageRGBInverseTransform(int t_x, int t_y, double *i_x, double *i_y, double xfactor, double yfactor, int xmin, int ymin, int x, int y, double *inv_matrix)
{
double rx, ry;
cdfMatrixTransformPoint(inv_matrix, t_x, t_y, &rx, &ry);
*i_x = xfactor*((float)rx - x) + xmin;
*i_y = yfactor*((float)ry - y) + ymin;
*i_x = xfactor*((double)rx - x) + xmin;
*i_y = yfactor*((double)ry - y) + ymin;
}

void cdImageRGBCalcDstLimits(cdCanvas* canvas, int x, int y, int w, int h, int *xmin, int *xmax, int *ymin, int *ymax, int* rect)
Expand Down
2 changes: 1 addition & 1 deletion src/cd_util.c
Expand Up @@ -66,7 +66,7 @@ int cdCalcZoom(int canvas_size,
int is_horizontal)
{
int offset;
float zoom_factor = (float)img_rect_size / (float)cnv_rect_size;
double zoom_factor = (double)img_rect_size / (double)cnv_rect_size;

/* valores default sem otimizacao */
*new_cnv_rect_size = cnv_rect_size, *new_cnv_rect_pos = cnv_rect_pos;
Expand Down
1 change: 0 additions & 1 deletion src/drv/cddgn.c
Expand Up @@ -326,7 +326,6 @@ static void put_long (cdCtxCanvas* ctxcanvas, unsigned long i)
static void put_as_double(cdCtxCanvas* ctxcanvas, long i)
{
float dfloat=(float) 4*i;

put_long(ctxcanvas, *((long *) &dfloat));
put_long(ctxcanvas, 0);
}
Expand Down

0 comments on commit 23dcea2

Please sign in to comment.