本文整理汇总了C++中cairo_status_to_string函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_status_to_string函数的具体用法?C++ cairo_status_to_string怎么用?C++ cairo_status_to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_status_to_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wglCreateContext
void CairoGLRenderer::InitDemo(HWND hWnd, HDC hdc)
{
RECT rect;
::GetClientRect(hWnd, &rect);
m_hdc = hdc;
m_hglrc = wglCreateContext(hdc);
long width = rect.right - rect.left;
long height = rect.bottom - rect.top;
m_device = cairo_wgl_device_create(m_hglrc);
if (cairo_device_status(m_device) != CAIRO_STATUS_SUCCESS)
printf("cairo device failed with %s\n", cairo_status_to_string(cairo_device_status(m_device)));
m_surface = cairo_gl_surface_create_for_dc(m_device, m_hdc, width, height);
if (cairo_surface_status(m_surface) != CAIRO_STATUS_SUCCESS)
{
const char* error = cairo_status_to_string(cairo_surface_status(m_surface));
fprintf(stderr, "cairo surface failed with %s\n", error);
}
m_cr = cairo_create (m_surface);
if (cairo_status(m_cr) != CAIRO_STATUS_SUCCESS)
printf("cairo failed with %s\n", cairo_status_to_string(cairo_status(m_cr)));
}
示例2: CAIRODrawLines
void CAIRODrawLines(cairo_t *cr,Gpoint *ype,int npnt,int mode)
{
int i;
/* printf("line: cr: %p\n",cr); */
if (mode != CoordModeOrigin ) {
printf("drawing lines in wrong coordmode! your mode: %i vs %i\n",mode,CoordModeOrigin);
exit(1);
}
cairo_move_to(cr,ype[0].x,ype[0].y);
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS ) {
fprintf(stderr,"NOOOOOOOOOOOO BAD MOVETO%s\n",cairo_status_to_string(cairo_status(cr)));
exit(1);
}
for(i=1;i<npnt;i++) {
cairo_line_to(cr,ype[i].x,ype[i].y);
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS ) {
fprintf(stderr,"NOOOOOOOOOOOO BAD LINETO%s\n",cairo_status_to_string(cairo_status(cr)));
exit(1);
}
}
cairo_stroke(cr);
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS ) {
fprintf(stderr,"NOOOOOOOOOOOO BAD STROKE%s\n",cairo_status_to_string(cairo_status(cr)));
exit(1);
}
}
示例3: render_cairo_surface
static void
render_cairo_surface (const RENDER * render, SNDFILE *infile, int samplerate, sf_count_t filelen)
{
cairo_surface_t * surface = NULL ;
cairo_status_t status ;
/*
** CAIRO_FORMAT_RGB24 each pixel is a 32-bit quantity, with the upper 8 bits
** unused. Red, Green, and Blue are stored in the remaining 24 bits in that order.
*/
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, render->width, render->height) ;
if (surface == NULL || cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
{ status = cairo_surface_status (surface) ;
printf ("Error while creating surface : %s\n", cairo_status_to_string (status)) ;
exit (1) ;
} ;
cairo_surface_flush (surface) ;
render_to_surface (render, infile, samplerate, filelen, surface) ;
status = cairo_surface_write_to_png (surface, render->pngfilepath) ;
if (status != CAIRO_STATUS_SUCCESS)
{ printf ("Error while creating PNG file : %s\n", cairo_status_to_string (status)) ;
exit (1) ;
} ;
cairo_surface_destroy (surface) ;
return ;
} /* render_cairo_surface */
示例4: CAIROFillPolygon
void CAIROFillPolygon(cairo_t *cr, Gpoint *ype, int npnt, int shape, int mode)
{
int i;
// printf("polyg: cr: %p\n",cr);
if (mode != CoordModeOrigin ){
printf("fill polygon in wrong coordmode, not implemented yet! your mode: %i vs %i\n",mode,CoordModeOrigin);
}
if (shape != Complex ) {
printf("fill polygon in wrong shape mode, not implemented yet!\nResults may be different from expected ones");
}
cairo_move_to(cr,ype[0].x,ype[0].y);
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS ) {
fprintf(stderr,"NOOOOOOOOOOOO BAD PMOVE TO: %s\n",cairo_status_to_string(cairo_status(cr)));
exit(1);
}
for(i=1;i<npnt;i++) {
cairo_line_to(cr,ype[i].x,ype[i].y);
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS ) {
fprintf(stderr,"NOOOOOOOOOOOO BAD PLINE TO: %s\n",cairo_status_to_string(cairo_status(cr)));
exit(1);
}
}
cairo_fill(cr);
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS ) {
fprintf(stderr,"NOOOOOOOOOOOO BAD PFILL%s\n",cairo_status_to_string(cairo_status(cr)));
exit(1);
}
}
示例5: Pycairo_Check_Status
int
Pycairo_Check_Status (cairo_status_t status)
{
if (PyErr_Occurred() != NULL)
return 1;
switch (status) {
case CAIRO_STATUS_SUCCESS:
return 0;
/* if appropriate - translate the status string into Python,
* else - use cairo_status_to_string()
*/
case CAIRO_STATUS_NO_MEMORY:
PyErr_NoMemory();
break;
case CAIRO_STATUS_READ_ERROR:
case CAIRO_STATUS_WRITE_ERROR:
PyErr_SetString(PyExc_IOError, cairo_status_to_string (status));
break;
case CAIRO_STATUS_INVALID_RESTORE:
PyErr_SetString(CairoError, "Context.restore without matching "
"Context.save");
break;
case CAIRO_STATUS_INVALID_POP_GROUP:
PyErr_SetString(CairoError, "Context.pop_group without matching "
"Context.push_group");
break;
default:
PyErr_SetString(CairoError, cairo_status_to_string (status));
}
return 1;
}
示例6: BM_Open
static Rboolean
BM_Open(pDevDesc dd, pX11Desc xd, int width, int height)
{
cairo_status_t res;
if (xd->type == PNG || xd->type == JPEG ||
xd->type == TIFF || xd->type == BMP) {
xd->cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
xd->windowWidth,
xd->windowHeight);
} else if (xd->type == PNGdirect) {
xd->cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
xd->windowWidth,
xd->windowHeight);
} else if(xd->type == SVG || xd->type == PDF || xd->type == PS) {
/* leave creation to BM_Newpage */
return TRUE;
} else
error(_("unimplemented cairo-based device"));
res = cairo_surface_status(xd->cs);
if (res != CAIRO_STATUS_SUCCESS) {
warning("cairo error '%s'", cairo_status_to_string(res));
return FALSE;
}
xd->cc = cairo_create(xd->cs);
res = cairo_status(xd->cc);
if (res != CAIRO_STATUS_SUCCESS) {
warning("cairo error '%s'", cairo_status_to_string(res));
return FALSE;
}
cairo_set_operator(xd->cc, CAIRO_OPERATOR_OVER);
cairo_reset_clip(xd->cc);
cairo_set_antialias(xd->cc, xd->antialias);
return TRUE;
}
示例7: args_parse
bool
args_parse (args_t *args, int argc, char **argv)
{
int i;
if (argc < 3) {
fprintf (stderr, "%s", copyright);
fprintf (stderr, "%s", usage);
return false;
}
for (i = 0; i < argc; i++) {
if (i == 1) {
args->surface_a = cairo_image_surface_create_from_png (argv[1]);
if (cairo_surface_status (args->surface_a))
{
fprintf (stderr, "FAIL: Cannot open %s: %s\n",
argv[1], cairo_status_to_string (cairo_surface_status (args->surface_a)));
return false;
}
} else if (i == 2) {
args->surface_b = cairo_image_surface_create_from_png (argv[2]);
if (cairo_surface_status (args->surface_b))
{
fprintf (stderr, "FAIL: Cannot open %s: %s\n",
argv[2], cairo_status_to_string (cairo_surface_status (args->surface_b)));
return false;
}
} else {
if (strstr(argv[i], "-fov")) {
if (i + 1 < argc) {
args->FieldOfView = (float) atof(argv[i + 1]);
}
} else if (strstr(argv[i], "-verbose")) {
args->Verbose = true;
} else if (strstr(argv[i], "-threshold")) {
if (i + 1 < argc) {
args->ThresholdPixels = atoi(argv[i + 1]);
}
} else if (strstr(argv[i], "-gamma")) {
if (i + 1 < argc) {
args->Gamma = (float) atof(argv[i + 1]);
}
}else if (strstr(argv[i], "-luminance")) {
if (i + 1 < argc) {
args->Luminance = (float) atof(argv[i + 1]);
}
}
}
} /* i */
return true;
}
示例8: main
int
main (int argc, char *argv[])
{
cairo_t *cr;
cairo_surface_t *argb, *rgb24;
cairo_status_t status;
const char *input, *output;
if (argc != 3) {
fprintf (stderr, "usage: %s input.png output.png", argv[0]);
fprintf (stderr, "Loads a PNG image (potentially with alpha) and writes out a flattened (no alpha)\nPNG image by first blending over white.\n");
return 1;
}
input = argv[1];
output = argv[2];
argb = cairo_image_surface_create_from_png (input);
status = cairo_surface_status (argb);
if (status) {
fprintf (stderr, "%s: Error: Failed to load %s: %s\n",
argv[0], input, cairo_status_to_string (status));
return 1;
}
rgb24 = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
cairo_image_surface_get_width (argb),
cairo_image_surface_get_height (argb));
cr = cairo_create (rgb24);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
cairo_paint (cr);
cairo_set_source_surface (cr, argb, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
status = cairo_surface_write_to_png (rgb24, output);
if (status) {
fprintf (stderr, "%s: Error: Failed to write %s: %s\n",
argv[0], output, cairo_status_to_string (status));
return 1;
}
return 0;
}
示例9: _cairo_script_render_page
static const char *
_cairo_script_render_page (const char *filename,
cairo_surface_t **surface_out)
{
cairo_script_interpreter_t *csi;
cairo_surface_t *surface = NULL;
cairo_status_t status;
const cairo_script_interpreter_hooks_t hooks = {
.closure = &surface,
.surface_create = _create_image,
};
csi = cairo_script_interpreter_create ();
cairo_script_interpreter_install_hooks (csi, &hooks);
cairo_script_interpreter_run (csi, filename);
status = cairo_script_interpreter_destroy (csi);
if (surface == NULL) {
return "cairo-script interpreter failed";
}
if (status == CAIRO_STATUS_SUCCESS)
status = cairo_surface_status (surface);
if (status) {
cairo_surface_destroy (surface);
return cairo_status_to_string (status);
}
*surface_out = surface;
return NULL;
}
示例10: conv_pdf
int
conv_pdf (RioData *data, const char *filename)
{
int status;
/* Determine original image height & width */
uint32_t height, width;
status = rio_data_get_metadata_uint32 (data, RIO_KEY_IMAGE_ROWS, &height)
&& rio_data_get_metadata_uint32 (data, RIO_KEY_IMAGE_COLS, &width);
if (!status) {
fprintf (stderr, "ERROR: Could not determine image dimensions.\n");
return 0;
}
/* Create output surface */
cairo_surface_t *pdf = cairo_pdf_surface_create (filename, width, height);
if (cairo_surface_status (pdf) != CAIRO_STATUS_SUCCESS) {
fprintf (stderr, "ERROR: Could not create PDF surface for %s: %s\n",
filename, cairo_status_to_string (cairo_surface_status (pdf)));
return 0;
}
/* FIXME naively assumes that all will be fine from now on. */
svg_draw (data, pdf);
cairo_surface_finish (pdf);
return 1;
}
示例11: addgra2cairo
void *
addgra2cairo()
/* addgra2cairoile() returns NULL on error */
{
int i;
if (CompatibleFontHash == NULL) {
CompatibleFontHash = nhash_new();
if (CompatibleFontHash == NULL) {
return NULL;
}
for (i = 0; i < (int) (sizeof(CompatibleFont) / sizeof(*CompatibleFont)); i++) {
nhash_set_int(CompatibleFontHash, CompatibleFont[i].old_name, i);
}
}
if (Gra2CairoErrMsgs == NULL) {
Gra2CairoErrMsgs = g_malloc(sizeof(*Gra2CairoErrMsgs) * CAIRO_STATUS_LAST_STATUS);
Gra2CairoErrMsgNum = CAIRO_STATUS_LAST_STATUS;
for (i = 0; i < CAIRO_STATUS_LAST_STATUS; i++) {
Gra2CairoErrMsgs[i] = g_strdup(cairo_status_to_string(i));
}
}
return addobject(NAME, NULL, PARENT, OVERSION, TBLNUM, gra2cairo, Gra2CairoErrMsgNum, Gra2CairoErrMsgs, NULL, NULL);
}
示例12: check_count
static cairo_bool_t
check_count (const cairo_test_context_t *ctx,
const char *message, cairo_bool_t uses_clip_rects,
cairo_rectangle_list_t *list, int expected)
{
if (!uses_clip_rects) {
if (expected == 0 && list->num_rectangles == 0)
return 1;
if (list->num_rectangles == expected)
return 1;
if (list->status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)
return 1;
cairo_test_log (ctx, "Error: %s; cairo_copy_clip_rectangle_list unexpectedly got %d rectangles\n",
message, list->num_rectangles);
return 0;
}
if (list->status != CAIRO_STATUS_SUCCESS) {
cairo_test_log (ctx, "Error: %s; cairo_copy_clip_rectangle_list failed with \"%s\"\n",
message, cairo_status_to_string(list->status));
return 0;
}
if (list->num_rectangles == expected)
return 1;
cairo_test_log (ctx, "Error: %s; expected %d rectangles, got %d\n", message,
expected, list->num_rectangles);
return 0;
}
示例13: preamble
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
int x,y;
int width = 10;
int height = 10;
cairo_surface_t *surf;
cairo_t *cr;
int false_positive_count = 0;
cairo_status_t status;
cairo_test_status_t ret;
surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
cr = cairo_create (surf);
cairo_surface_destroy (surf);
/* Empty horizontal trapezoid. */
cairo_move_to (cr, 0, height/3);
cairo_line_to (cr, width, height/3);
cairo_close_path (cr);
/* Empty non-horizontal trapezoid #1. */
cairo_move_to (cr, 0, 0);
cairo_line_to (cr, width, height/2);
cairo_close_path (cr);
/* Empty non-horizontal trapezoid #2 intersecting #1. */
cairo_move_to (cr, 0, height/2);
cairo_line_to (cr, width, 0);
cairo_close_path (cr);
status = cairo_status (cr);
/* Point sample the tessellated path. */
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (cairo_in_fill (cr, x, y)) {
false_positive_count++;
}
}
}
cairo_destroy (cr);
/* Check that everything went well. */
ret = CAIRO_TEST_SUCCESS;
if (CAIRO_STATUS_SUCCESS != status) {
cairo_test_log (ctx, "Failed to create a test surface and path: %s\n",
cairo_status_to_string (status));
ret = CAIRO_TEST_XFAILURE;
}
if (0 != false_positive_count) {
cairo_test_log (ctx, "Point sampling found %d false positives "
"from cairo_in_fill()\n",
false_positive_count);
ret = CAIRO_TEST_XFAILURE;
}
return ret;
}
示例14: font_fc
explicit font_fc(cairo_t* cairo, FcPattern* pattern, double offset, double dpi_x, double dpi_y) : font(cairo, offset), m_pattern(pattern) {
cairo_matrix_t fm;
cairo_matrix_t ctm;
cairo_matrix_init_scale(&fm, size(dpi_x), size(dpi_y));
cairo_get_matrix(m_cairo, &ctm);
auto fontface = cairo_ft_font_face_create_for_pattern(m_pattern);
auto opts = cairo_font_options_create();
m_scaled = cairo_scaled_font_create(fontface, &fm, &ctm, opts);
cairo_font_options_destroy(opts);
cairo_font_face_destroy(fontface);
auto status = cairo_scaled_font_status(m_scaled);
if (status != CAIRO_STATUS_SUCCESS) {
throw application_error(sstream() << "cairo_scaled_font_create(): " << cairo_status_to_string(status));
}
auto lock = make_unique<utils::ft_face_lock>(m_scaled);
auto face = static_cast<FT_Face>(*lock);
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) == FT_Err_Ok) {
return;
} else if (FT_Select_Charmap(face, FT_ENCODING_BIG5) == FT_Err_Ok) {
return;
} else if (FT_Select_Charmap(face, FT_ENCODING_SJIS) == FT_Err_Ok) {
return;
}
lock.reset();
}
示例15: draw_screen
/* Shows how to draw with Cairo on SDL surfaces */
static void
draw_screen (SDL_Surface *screen)
{
cairo_t *cr;
cairo_status_t status;
/* Create a cairo drawing context, normalize it and draw a clock. */
SDL_LockSurface (screen); {
cr = cairosdl_create (screen);
cairo_scale (cr, screen->w, screen->h);
draw (cr);
status = cairo_status (cr);
cairosdl_destroy (cr);
}
SDL_UnlockSurface (screen);
SDL_Flip (screen);
/* Nasty nasty error handling. */
if (status != CAIRO_STATUS_SUCCESS) {
fprintf (stderr, "Unable to create or draw with a cairo context "
"for the screen: %s\n",
cairo_status_to_string (status));
exit (1);
}
}