当前位置: 首页>>代码示例>>C++>>正文


C++ cairo_surface_write_to_png函数代码示例

本文整理汇总了C++中cairo_surface_write_to_png函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_surface_write_to_png函数的具体用法?C++ cairo_surface_write_to_png怎么用?C++ cairo_surface_write_to_png使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cairo_surface_write_to_png函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawerSave

void DrawerSave(Drawer * self, char fileTypePDF, const char * filePath) {
	if(fileTypePDF) {
		cairo_show_page(self->context);
	} else {
		cairo_surface_write_to_png(self->surface, filePath);
	}
}
开发者ID:BrunoGeorgevich,项目名称:P1Charts,代码行数:7,代码来源:drawing.c

示例2: main

int main (int argc, char **argv)
{
  GList *toplevels;
  GList *node;

  /* If there's no DISPLAY, we silently error out.  We don't want to break
   * headless builds. */
  if (! gtk_init_check (&argc, &argv))
    return 0;

  toplevels = get_all_widgets ();

  for (node = toplevels; node; node = g_list_next (node))
    {
      WidgetInfo *info;
      char *filename;
      cairo_surface_t *surface;

      info = node->data;

      gtk_widget_show (info->window);

      surface = snapshot_widget (info->window,
                                 info->include_decorations ? SNAPSHOT_WINDOW : SNAPSHOT_DRAW);
      filename = g_strdup_printf ("./%s.png", info->name);
      g_assert (cairo_surface_write_to_png (surface, filename) == CAIRO_STATUS_SUCCESS);
      g_free (filename);
      cairo_surface_destroy (surface);
    }

  return 0;
}
开发者ID:3dfxmadscientist,项目名称:gtk,代码行数:32,代码来源:shooter.c

示例3: renderLabels

	void renderLabels(const char* path)
	{
		BOOST_TEST_MESSAGE("Render: " << path);

		cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
			META_TILE_SIZE * TILE_SIZE, META_TILE_SIZE * TILE_SIZE);
		cairo_t* cr = cairo_create(surface);
		cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);

		cairo_save(cr);
		cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0);
		cairo_paint(cr);
		cairo_restore(cr);

		std::vector<std::pair<string, FloatPoint>> toPlace;
		toPlace.push_back(std::pair<string, FloatPoint>("Karlsruhe", FloatPoint(40, 200)));
		toPlace.push_back(std::pair<string, FloatPoint>("Mannheim", FloatPoint(400, 200)));
		toPlace.push_back(std::pair<string, FloatPoint>("Stuttgard", FloatPoint(200, 260)));
		toPlace.push_back(std::pair<string, FloatPoint>("München", FloatPoint(380, 660)));
		toPlace.push_back(std::pair<string, FloatPoint>("Pforzheim", FloatPoint(200, 600)));
		toPlace.push_back(std::pair<string, FloatPoint>("Wien", FloatPoint(240, 680)));
		toPlace.push_back(std::pair<string, FloatPoint>("Paris", FloatPoint(40, 880)));
		toPlace.push_back(std::pair<string, FloatPoint>("Rom", FloatPoint(-40, 880)));
		toPlace.push_back(std::pair<string, FloatPoint>("Nothing", FloatPoint(400, 760)));
		toPlace.push_back(std::pair<string, FloatPoint>("To See", FloatPoint(720, 880)));
		toPlace.push_back(std::pair<string, FloatPoint>("Here", FloatPoint(720, 560)));
		toPlace.push_back(std::pair<string, FloatPoint>("Bielefeld", FloatPoint(420, 840)));
		renderer->renderLabels(cr, toPlace);

		BOOST_TEST_MESSAGE("Writing.");
		cairo_surface_flush(surface);
		cairo_surface_write_to_png(surface, path);
	}
开发者ID:alex85k,项目名称:alacarte,代码行数:33,代码来源:placement_test.cpp

示例4: writeToPNG_func

/* Methods */
static JSBool
writeToPNG_func(JSContext *context,
                uintN      argc,
                jsval     *vp)
{
    jsval *argv = JS_ARGV(context, vp);
    JSObject *obj = JS_THIS_OBJECT(context, vp);
    char *filename;
    cairo_surface_t *surface;

    if (!gjs_parse_args(context, "writeToPNG", "s", argc, argv,
                        "filename", &filename))
        return JS_FALSE;

    surface = gjs_cairo_surface_get_surface(context, obj);
    if (!surface) {
        g_free(filename);
        return JS_FALSE;
    }
    cairo_surface_write_to_png(surface, filename);
    g_free(filename);
    if (!gjs_cairo_check_status(context, cairo_surface_status(surface),
                                "surface"))
        return JS_FALSE;
    JS_SET_RVAL(context, vp, JSVAL_VOID);
    return JS_TRUE;
}
开发者ID:BabeNovelty,项目名称:glib-win32,代码行数:28,代码来源:cairo-surface-vs10.c

示例5: ng_view_export_to_file

void ng_view_export_to_file(NgView *view, const gchar *filename)
{
    g_return_if_fail(view != NULL);
    g_return_if_fail(view->ng != NULL);
    g_return_if_fail(filename != NULL);

    NgView *offscreen = ng_view_new(view->ng);

    guint width = 0, height = 0;
    ng_view_get_required_size(offscreen, &width, &height);
    if (width == 0 || height == 0)
        goto done;
    ng_view_set_size(offscreen, width, height);

    cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
    cairo_t *cr = cairo_create(surf);

    ng_view_render(offscreen, cr, FALSE);

    cairo_destroy(cr);

    cairo_status_t status = cairo_surface_write_to_png(surf, filename);
    cairo_surface_destroy(surf);

    if (status != CAIRO_STATUS_SUCCESS)
        printf("Error exporting to file `%s'\n", filename);

done:
    ng_view_unref(offscreen);
}
开发者ID:lahol,项目名称:nonogram-game,代码行数:30,代码来源:ng-view.c

示例6: main

int main (int argc, char **argv)
{
  cairo_t *cr;
  char *filename;
  cairo_status_t status;
  cairo_surface_t *surface;
  if (argc != 2)
    {
      g_printerr ("Usage: cairosimple OUTPUT_FILENAME\n");
      return 1;
    }
  filename = argv[1];
  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                    2 * RADIUS, 2 * RADIUS);
  cr = cairo_create (surface);
  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
  cairo_paint (cr);
  draw_text (cr);
  cairo_destroy (cr);
  status = cairo_surface_write_to_png (surface, filename);
  cairo_surface_destroy (surface);
  if (status != CAIRO_STATUS_SUCCESS)
    {
      g_printerr ("Could not save png to '%s'\n", filename);
      return 1;
    }
  return 0;
}
开发者ID:Anomalous-Software,项目名称:CMake,代码行数:28,代码来源:main.c

示例7: cairo_surface_write_to_png

 void CairoPainter::WriteImage(const std::string &filename)
 {
   if (!m_cairo || !m_surface)
     return;
   
   cairo_surface_write_to_png(m_surface, filename.c_str());
 }
开发者ID:ghutchis,项目名称:openbabel,代码行数:7,代码来源:cairopainter.cpp

示例8: GetDesktopWindow

void PlatformBinding::TakeScreenshotImpl(const std::string& targetFile)
{
    // Ensure filename ends in .bmp.
    // TODO: This seems broken.
    std::string screenshotFile = targetFile;
    if (screenshotFile.rfind(".") == std::string::npos)
        screenshotFile.append(".png");

    HWND desktop = GetDesktopWindow();
    RECT desktopRect;
    GetWindowRect(desktop, &desktopRect);

    int width = desktopRect.right;
    int height = desktopRect.bottom;

    cairo_surface_t* surface = cairo_win32_surface_create_with_dib(CAIRO_FORMAT_RGB24, width, height);
    cairo_surface_flush(surface);

    HDC hdc = cairo_win32_surface_get_dc(surface);
    BitBlt(hdc, 0, 0, width, height, GetDC(0), 0, 0, SRCCOPY);

    std::string filename(::UTF8ToSystem(screenshotFile));
    cairo_status_t result = cairo_surface_write_to_png(surface, filename.c_str());

    cairo_surface_destroy(surface);

    if (result != CAIRO_STATUS_SUCCESS)
        throw ValueException::FromString("Could not save screenshot.");
}
开发者ID:Adimpression,项目名称:TideSDK,代码行数:29,代码来源:platform_binding_win32.cpp

示例9: finish

void finish(void)
{
	if(!surface || !cr) return;
	cairo_surface_write_to_png(surface, __FILE__ ".png");
	cairo_destroy(cr);
	cairo_surface_destroy(surface);
}
开发者ID:letoh,项目名称:WSFN,代码行数:7,代码来源:koch_cairo.c

示例10: n_harm_osz_print_cairo

void n_harm_osz_print_cairo(r_type r, int t)
{
    int i;
    cairo_surface_t *surface;
    cairo_t *cr;
    char filename[40];

    sprintf(filename, "n_harm_osz/n_harm_osz_%04d.png", t);

    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, CAIRO_XSCALE*CAIRO_SCALE, CAIRO_YSCALE*CAIRO_SCALE);
    cr = cairo_create (surface);

    /* weißer Hintergrund */
    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_paint (cr);

    /* Drawing code goes here */
    for(i=0; i < r.N ; i++)
    {
        cairo_set_source_rgb (cr, VMIN(fabs(r.vx[i]/VMAX)), VMIN(fabs(r.vy[i]/VMAX)), VMIN(fabs(r.vz[i]/VMAX)));
        cairo_rectangle (cr, (int) (r.x[i]*CAIRO_SCALE*0.8+0.1*CAIRO_XSCALE*CAIRO_SCALE), (int) (r.y[i]*CAIRO_SCALE*0.8+0.1*CAIRO_YSCALE*CAIRO_SCALE), 1*SCALE, 1*SCALE);
        cairo_fill (cr);
    }

    /* Write output and clean up */
    cairo_surface_write_to_png (surface, filename);
    cairo_destroy (cr);
    cairo_surface_destroy (surface);
}
开发者ID:surt91,项目名称:-bungen-in-C,代码行数:29,代码来源:n_harm_osz.c

示例11: main

int main(void)
{
	int i;
	int width, height;
	width = 600;
	height = 100;

	cairo_surface_t *surface;
	cairo_t *cr;
	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
	cr = cairo_create(surface); 

	for ( i = 1; i <= 10; i++) {
      		cairo_set_source_rgba(cr, 0, 0, 1, i*0.1);
	    	cairo_rectangle(cr, 50*i, 40, 40, 40);
     		cairo_fill(cr);  
 	}      

	cairo_surface_write_to_png(surface, "transparancy.png");

	cairo_destroy(cr);
	cairo_surface_destroy(surface);
	
	return 0;
}
开发者ID:eamadosuarez,项目名称:Cairo-Tutorial,代码行数:25,代码来源:cairo-transparancy.c

示例12: main

int main(int argc, char** argv)
{
    cairo_surface_t *surface;
    cairo_t *cr;
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1300, 760);
    cr = cairo_create (surface);

int w, h;
cairo_surface_t *image;

cairo_arc (cr, 128.0, 128.0, 76.8, 0, 2*M_PI);
cairo_clip (cr);
cairo_new_path (cr); /* path not consumed by clip()*/

image = cairo_image_surface_create_from_png ("new.png");
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);

cairo_scale (cr, 256.0/w, 256.0/h);

cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);

cairo_surface_destroy (image);
    cairo_destroy (cr);
    cairo_surface_write_to_png (surface, "hello.png");
    cairo_surface_destroy (surface);

    return 0;
}
开发者ID:mandeeps708,项目名称:hatching,代码行数:30,代码来源:img.c

示例13: gdk_texture_save_to_png

/**
 * gdk_texture_save_to_png:
 * @texture: a #GdkTexture
 * @filename: the filename to store to
 *
 * Store the given @texture to the @filename as a PNG file.
 *
 * This is a utility function intended for debugging and testing.
 * If you want more control over formats, proper error handling or
 * want to store to a #GFile or other location, you might want to
 * look into using the gdk-pixbuf library.
 *
 * Returns: %TRUE if saving succeeded, %FALSE on failure.
 **/
gboolean
gdk_texture_save_to_png (GdkTexture *texture,
                         const char *filename)
{
  cairo_surface_t *surface;
  cairo_status_t status;
  gboolean result;

  g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
  g_return_val_if_fail (filename != NULL, FALSE);

  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                        gdk_texture_get_width (texture),
                                        gdk_texture_get_height (texture));
  gdk_texture_download (texture,
                        cairo_image_surface_get_data (surface),
                        cairo_image_surface_get_stride (surface));
  cairo_surface_mark_dirty (surface);

  status = cairo_surface_write_to_png (surface, filename);

  if (status != CAIRO_STATUS_SUCCESS ||
      cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
    result = FALSE;
  else
    result = TRUE;

  cairo_surface_destroy (surface);

  return result;
}
开发者ID:GNOME,项目名称:gtk,代码行数:45,代码来源:gdktexture.c

示例14: btn_save_cb

G_MODULE_EXPORT
void btn_save_cb(GtkButton *btn, gpointer data)
{
	cairo_t *cr;
	cairo_surface_t *surface;
	int i;
	double y;

	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 512, 500);
	cr = cairo_create (surface);

	paint_bg(cr);
	paint_marker(cr);

	//画图(蓝色)
	cairo_set_line_width(cr, 1);
	cairo_set_source_rgb(cr, 0, 0, 1);
	y = TOY(buffer[0])>500 ? 500 : TOY(buffer[0]);
	cairo_move_to(cr, 0, TOY(buffer[0]));
	for (i=1; i<512; i++) {
		y = cfg.yref + yscale*TOY(buffer[i-1]);
		//cairo_line_to(cr, i-1, cfg.yref+yscale*TOY(buffer[i-1]));
		cairo_line_to(cr, i-1, y>500?500:y);
	}
	cairo_stroke(cr);

	cairo_surface_write_to_png(surface, "save.png");

	cairo_destroy(cr);
	cairo_surface_destroy(surface);
}
开发者ID:athurg,项目名称:adcap,代码行数:31,代码来源:adcap.c

示例15: render_rectangle

void render_rectangle(char *filename) {

  cairo_surface_t *surface;
  cairo_t *cr;
  int width;
  int height;
  int rec_x;
  int rec_y;
  int rec_width;
  int rec_height;

  width = 1280;
  height = 720;
  rec_x = 320;
  rec_y = 240;
  rec_width = 30;
  rec_height = 300;

  surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
  cr = cairo_create(surface);
  // Fill with white (default is transparent)
  cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
  cairo_paint(cr);
  krad_vector_render_rrect(cr, rec_x, rec_y, rec_width, rec_height,
   0.8, 0.2, 0.2, 0.5);
  cairo_surface_write_to_png(surface, filename);
  cairo_destroy(cr);
  cairo_surface_destroy(surface);
}
开发者ID:kripton,项目名称:krad_radio-1,代码行数:29,代码来源:cairo_sandbox.c


注:本文中的cairo_surface_write_to_png函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。