本文整理汇总了C++中RINT函数的典型用法代码示例。如果您正苦于以下问题:C++ RINT函数的具体用法?C++ RINT怎么用?C++ RINT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RINT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gimp_operation_posterize_process
static gboolean
gimp_operation_posterize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat levels;
if (! config)
return FALSE;
levels = config->levels - 1.0;
while (samples--)
{
dest[RED] = RINT (src[RED] * levels) / levels;
dest[GREEN] = RINT (src[GREEN] * levels) / levels;
dest[BLUE] = RINT (src[BLUE] * levels) / levels;
dest[ALPHA] = src[ALPHA];
src += 4;
dest += 4;
}
return TRUE;
}
示例2: compute_preview_rectangle
static void
compute_preview_rectangle (gint * xp, gint * yp, gint * wid, gint * heig)
{
gdouble x, y, w, h;
if (width >= height)
{
w = (PREVIEW_WIDTH - 50.0);
h = (gdouble) height *(w / (gdouble) width);
x = (PREVIEW_WIDTH - w) / 2.0;
y = (PREVIEW_HEIGHT - h) / 2.0;
}
else
{
h = (PREVIEW_HEIGHT - 50.0);
w = (gdouble) width *(h / (gdouble) height);
x = (PREVIEW_WIDTH - w) / 2.0;
y = (PREVIEW_HEIGHT - h) / 2.0;
}
*xp = RINT (x);
*yp = RINT (y);
*wid = RINT (w);
*heig = RINT (h);
}
示例3: gimp_operation_posterize_process
static gboolean
gimp_operation_posterize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level)
{
GimpOperationPosterize *posterize = GIMP_OPERATION_POSTERIZE (operation);
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat levels;
levels = posterize->levels - 1.0;
while (samples--)
{
dest[RED] = RINT (src[RED] * levels) / levels;
dest[GREEN] = RINT (src[GREEN] * levels) / levels;
dest[BLUE] = RINT (src[BLUE] * levels) / levels;
dest[ALPHA] = RINT (src[ALPHA] * levels) / levels;
src += 4;
dest += 4;
}
return TRUE;
}
示例4: offset_response
static void
offset_response (GtkWidget *widget,
gint response_id,
OffsetDialog *dialog)
{
if (response_id == GTK_RESPONSE_OK)
{
GimpImage *image = dialog->image;
if (image)
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
gint offset_x;
gint offset_y;
offset_x =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->off_se),
0));
offset_y =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->off_se),
1));
gimp_drawable_offset (drawable,
dialog->context,
dialog->fill_type & WRAP_AROUND ? TRUE : FALSE,
dialog->fill_type & FILL_MASK,
offset_x, offset_y);
gimp_image_flush (image);
}
}
gtk_widget_destroy (dialog->dialog);
}
示例5: update_values
static void
update_values (void)
{
GtkWidget *entry;
entry = g_object_get_data (G_OBJECT (main_dialog), "width");
grid_cfg.hwidth =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 0));
grid_cfg.vwidth =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 1));
grid_cfg.iwidth =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2));
entry = g_object_get_data (G_OBJECT (main_dialog), "space");
grid_cfg.hspace =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 0));
grid_cfg.vspace =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 1));
grid_cfg.ispace =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2));
entry = g_object_get_data (G_OBJECT (main_dialog), "offset");
grid_cfg.hoffset =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 0));
grid_cfg.voffset =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 1));
grid_cfg.ioffset =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2));
}
示例6: gimp_drawable_get_sub_preview
GimpTempBuf *
gimp_drawable_get_sub_preview (GimpDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height)
{
GimpItem *item;
GimpImage *image;
GeglBuffer *buffer;
GimpTempBuf *preview;
gdouble scale;
gint scaled_x;
gint scaled_y;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (src_x >= 0, NULL);
g_return_val_if_fail (src_y >= 0, NULL);
g_return_val_if_fail (src_width > 0, NULL);
g_return_val_if_fail (src_height > 0, NULL);
g_return_val_if_fail (dest_width > 0, NULL);
g_return_val_if_fail (dest_height > 0, NULL);
item = GIMP_ITEM (drawable);
g_return_val_if_fail ((src_x + src_width) <= gimp_item_get_width (item), NULL);
g_return_val_if_fail ((src_y + src_height) <= gimp_item_get_height (item), NULL);
image = gimp_item_get_image (item);
if (! image->gimp->config->layer_previews)
return NULL;
buffer = gimp_drawable_get_buffer (drawable);
preview = gimp_temp_buf_new (dest_width, dest_height,
gimp_drawable_get_preview_format (drawable));
scale = MIN ((gdouble) dest_width / (gdouble) src_width,
(gdouble) dest_height / (gdouble) src_height);
scaled_x = RINT ((gdouble) src_x * scale);
scaled_y = RINT ((gdouble) src_y * scale);
gegl_buffer_get (buffer,
GEGL_RECTANGLE (scaled_x, scaled_y, dest_width, dest_height),
scale,
gimp_temp_buf_get_format (preview),
gimp_temp_buf_get_data (preview),
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_CLAMP);
return preview;
}
示例7: process
static gboolean process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level)
{
GeglProperties *o = GEGL_PROPERTIES (operation);
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat levels = o->levels;
while (samples--)
{
gint i;
for (i=0; i < 3; i++)
dest[i] = RINT (src[i] * levels) / levels;
dest[3] = src[3];
src += 4;
dest += 4;
}
return TRUE;
}
示例8: p_mod
static Term
p_mod(Term t1, Term t2 USES_REGS) {
switch (ETypeOfTerm(t1)) {
case (CELL)long_int_e:
switch (ETypeOfTerm(t2)) {
case (CELL)long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1);
Int i2 = IntegerOfTerm(t2);
Int mod;
if (i2 == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " mod 0", i1);
if (i1 == Int_MIN && i2 == -1) {
return MkIntTerm(0);
}
mod = i1%i2;
if (mod && (mod ^ i2) < 0)
mod += i2;
RINT(mod);
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
return Yap_gmp_mod_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
break;
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
/* modulo between bignum and integer */
{
Int i2 = IntegerOfTerm(t2);
if (i2 == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... mod 0");
return Yap_gmp_mod_big_int(t1, i2);
}
case (CELL)big_int_e:
/* two bignums */
return Yap_gmp_mod_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
}
示例9: gimp_int_adjustment_update
/**
* gimp_int_adjustment_update:
* @adjustment: A #GtkAdjustment.
* @data: A pointer to a #gint variable which will store the
* @adjustment's value.
*
* Note that the #GtkAdjustment's value (which is a #gdouble) will be
* rounded with RINT().
**/
void
gimp_int_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
{
gint *val = (gint *) data;
*val = RINT (gtk_adjustment_get_value (adjustment));
}
示例10: p_rem
static Term
p_rem(Term t1, Term t2) {
switch (ETypeOfTerm(t1)) {
case (CELL)long_int_e:
switch (ETypeOfTerm(t2)) {
case (CELL)long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1);
Int i2 = IntegerOfTerm(t2);
Int mod;
if (i2 == 0) goto zero_divisor;
if (i1 == Int_MIN && i2 == -1) {
#ifdef USE_GMP
return Yap_gmp_add_ints(Int_MAX, 1);
#else
return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1,
"rem/2 with %d and %d", i1, i2);
#endif
}
mod = i1%i2;
RINT(i1%i2);
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
return Yap_gmp_rem_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
}
break;
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
return Yap_gmp_rem_big_int(t1, IntegerOfTerm(t2));
case (CELL)big_int_e:
/* two bignums */
return Yap_gmp_rem_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
zero_divisor:
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is mod 0");
}
示例11: rgb_to_hsl
static guchar*
rgb_to_hsl (GimpDrawable *drawable,
LICEffectChannel effect_channel)
{
guchar *themap, data[4];
gint x, y;
GimpRGB color;
GimpHSL color_hsl;
gdouble val = 0.0;
glong maxc, index = 0;
GimpPixelRgn region;
GRand *gr;
gr = g_rand_new ();
maxc = drawable->width * drawable->height;
gimp_pixel_rgn_init (®ion, drawable, border_x, border_y,
border_w, border_h, FALSE, FALSE);
themap = g_new (guchar, maxc);
for (y = 0; y < region.h; y++)
{
for (x = 0; x < region.w; x++)
{
data[3] = 255;
gimp_pixel_rgn_get_pixel (®ion, data, x, y);
gimp_rgba_set_uchar (&color, data[0], data[1], data[2], data[3]);
gimp_rgb_to_hsl (&color, &color_hsl);
switch (effect_channel)
{
case LIC_HUE:
val = color_hsl.h * 255;
break;
case LIC_SATURATION:
val = color_hsl.s * 255;
break;
case LIC_BRIGHTNESS:
val = color_hsl.l * 255;
break;
}
/* add some random to avoid unstructured areas. */
val += g_rand_double_range (gr, -1.0, 1.0);
themap[index++] = (guchar) CLAMP0255 (RINT (val));
}
}
g_rand_free (gr);
return themap;
}
示例12: normhist
/* Normalise the histogram so that it integrates to unity, taking the width of
* the bins into account.
* nh - number of histogram bins
* h - histogram
* binwidth - width of each histogram bin (1/scale)
*
* required: nh, h, binwidth
* modified: h
*/
static void normhist(int nh, double h[], double binwidth, int *psh)
{
double sh = 0.0;
int i;
for(i=0; i<nh; i++)
sh += h[i];
for(i=0; i<nh; i++)
h[i]/= binwidth*sh;
*psh = RINT(sh);
}
示例13: av_q2d
/*
* Calculate the height and width this video should be displayed in
*/
void CDVDVideoCodecFFmpeg::GetVideoAspect(AVCodecContext* pCodecContext, unsigned int& iWidth, unsigned int& iHeight)
{
double aspect_ratio;
/* XXX: use variable in the frame */
if (pCodecContext->sample_aspect_ratio.num == 0) aspect_ratio = 0;
else aspect_ratio = av_q2d(pCodecContext->sample_aspect_ratio) * pCodecContext->width / pCodecContext->height;
if (aspect_ratio <= 0.0) aspect_ratio = (float)pCodecContext->width / (float)pCodecContext->height;
/* XXX: we suppose the screen has a 1.0 pixel ratio */ // CDVDVideo will compensate it.
iHeight = pCodecContext->height;
iWidth = ((int)RINT(pCodecContext->height * aspect_ratio)) & -3;
if (iWidth > (unsigned int)pCodecContext->width)
{
iWidth = pCodecContext->width;
iHeight = ((int)RINT(pCodecContext->width / aspect_ratio)) & -3;
}
}
示例14: draw_line
static gint
draw_line (gint n,
gint startx,
gint starty,
gint pw,
gint ph,
gdouble cx1,
gdouble cy1,
gdouble cx2,
gdouble cy2,
GimpVector3 a,
GimpVector3 b)
{
gdouble x1, y1, x2, y2;
gint i = n;
gimp_vector_3d_to_2d (startx, starty, pw, ph,
&x1, &y1, &mapvals.viewpoint, &a);
gimp_vector_3d_to_2d (startx, starty, pw, ph,
&x2, &y2, &mapvals.viewpoint, &b);
if (clip_line (&x1, &y1, &x2, &y2, cx1, cy1, cx2, cy2) == TRUE)
{
linetab[i].x1 = RINT (x1);
linetab[i].y1 = RINT (y1);
linetab[i].x2 = RINT (x2);
linetab[i].y2 = RINT (y2);
linetab[i].linewidth = 3;
linetab[i].linestyle = GDK_LINE_SOLID;
gdk_gc_set_line_attributes (gc,
linetab[i].linewidth,
linetab[i].linestyle,
GDK_CAP_NOT_LAST,
GDK_JOIN_MITER);
gdk_draw_line (previewarea->window, gc,
linetab[i].x1, linetab[i].y1,
linetab[i].x2, linetab[i].y2);
i++;
}
return i;
}
示例15: gimp_brush_generated_calc_lut
/* set up lookup table */
static guchar *
gimp_brush_generated_calc_lut (gdouble radius,
gdouble hardness)
{
guchar *lookup;
gint length;
gint x;
gdouble d;
gdouble sum;
gdouble exponent;
gdouble buffer[OVERSAMPLING];
length = OVERSAMPLING * ceil (1 + sqrt (2 * SQR (ceil (radius + 1.0))));
lookup = g_malloc (length);
sum = 0.0;
if ((1.0 - hardness) < 0.0000004)
exponent = 1000000.0;
else
exponent = 0.4 / (1.0 - hardness);
for (x = 0; x < OVERSAMPLING; x++)
{
d = fabs ((x + 0.5) / OVERSAMPLING - 0.5);
if (d > radius)
buffer[x] = 0.0;
else
buffer[x] = gauss (pow (d / radius, exponent));
sum += buffer[x];
}
for (x = 0; d < radius || sum > 0.00001; d += 1.0 / OVERSAMPLING)
{
sum -= buffer[x % OVERSAMPLING];
if (d > radius)
buffer[x % OVERSAMPLING] = 0.0;
else
buffer[x % OVERSAMPLING] = gauss (pow (d / radius, exponent));
sum += buffer[x % OVERSAMPLING];
lookup[x++] = RINT (sum * (255.0 / OVERSAMPLING));
}
while (x < length)
{
lookup[x++] = 0;
}
return lookup;
}