• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cairo_surface_write_to_png函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: main

int
main (int argc, char *argv[])
{
        cairo_surface_t *surface = //Sets the Cairo surface context
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 421, 410); //Creates Cairo image surface, sets image resolution.
        cairo_t *cr = //Declare *cr as a Cairo context.
            cairo_create (surface); //Sets the Cairo context as a pointer, *cr.

	/* Sixth triangle */
        cairo_scale (cr, 10, 10); //This is for the outlines only; scaling will mess up already-generated PNGs 
	cairo_move_to (cr, 12.8, 33.0); //This will be removed (probably) in the next revision.
	cairo_line_to (cr, 19.5, 26.0); //Draws a line from Point A to Point B.
	cairo_move_to (cr, 19.5, 26.0); //This will be removed (probably) in the next revision.
	cairo_line_to (cr, 33.3, 35.6); //Draws a line from Point B to Point C.
	cairo_move_to (cr, 33.3, 35.6); //This will be removed (probably) in the next revision.
	cairo_line_to (cr, 12.8, 33.0); //Draws a line from Point C back to Point A.

        cairo_set_line_width (cr, 0.1);	//This is an outline, so the width of the line that makes the shape up here is 0.1px thick.
	cairo_stroke (cr); //Draw the final shape

	/* Write output and clean up */
        cairo_surface_write_to_png (surface, "../images/triangle6-outline.png"); //Name the resulting image as triangle6-outline.png
        cairo_destroy (cr); //Destroy the context pointer, frees up memory and/or lag
        cairo_surface_destroy (surface); //Destroy the surface pointer, frees up memory and/or lag

        return 0; //No numbers needed!!
}
开发者ID:Christoffen-Corporation,项目名称:logo-generator.old,代码行数:27,代码来源:sixth-triangle.c


示例17: main

int
main (int argc, char *argv[])
{
        cairo_surface_t *surface = //Sets the Cairo surface context
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 421, 410); //Creates Cairo image surface, sets image resolution.
        cairo_t *cr = //Declare *cr as a Cairo context.
            cairo_create (surface); //Sets the Cairo context as a pointer, *cr.

	/* Second triangle */
	cairo_set_source_rgba (cr, 0.60, 0.85, 0.91, 0.8); //Sets the color of the triangle.
	cairo_line_to (cr, 275, 44); //Draws a line from Point A to Point B.
	cairo_line_to (cr, 377, 102); //Draws a line from Point B to Point C.
	cairo_line_to (cr, 100, 118); //Draws a line from Point C back to Point A.	
	cairo_close_path (cr); //Finishes the connections between Points A and C, closes off the figure.

	cairo_fill_preserve (cr); //Preserve fill so shape doesn't output as an outline.
	cairo_set_source_rgba (cr, 0.60, 0.85, 0.91, 0.8); //Sets the color of the triangle (again)
	cairo_stroke (cr); //Draw the final shape

	/* Write output and clean up */
        cairo_surface_write_to_png (surface, "../images/triangle2-color.png"); //Name the resulting image as triangle2-color.png
        cairo_destroy (cr); //Destroy the context pointer, frees up memory and/or lag
        cairo_surface_destroy (surface); //Destroy the surface pointer, frees up memory and/or lag

        return 0; //No numbers needed!!
}
开发者ID:Christoffen-Corporation,项目名称:logo-generator.old,代码行数:26,代码来源:second-triangle-color.c


示例18: main

int main() {
	// Auflösung in Pixeln
	const double res = 1000;
	const double xsize = res;
	const double ysize = sin(M_PI / 3) * res;

	// Breite einer Linie in Pixeln
	const double line_width = 3;

	// maximale Anzahl Iterationen
	const unsigned int iterations = 7;

	cairo_surface_t *surface = cairo_image_surface_create (
    	CAIRO_FORMAT_ARGB32, xsize, ysize);
    cairo_t *cr = cairo_create (surface);

    cairo_scale(cr, res, res);

    cairo_set_line_width (cr, line_width / res);
	cairo_set_source_rgb (cr, 0, 0, 0);

	const double space = 0.05;

	zeichne(cr, space, sin(M_PI / 3) - space, 1 - space,
		sin(M_PI / 3) - space, 0.5, space, iterations);

	cairo_destroy (cr);
    cairo_surface_write_to_png (surface, "sierpinski.png");
    cairo_surface_destroy (surface);
		
	return 0;
}
开发者ID:kempkens,项目名称:ephi-fraktale,代码行数:32,代码来源:sierpinski.cpp


示例19: 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 */
开发者ID:erikd,项目名称:sndfile-tools,代码行数:32,代码来源:spectrogram.c


示例20: draw_map

void draw_map(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);
  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_paint(cr);
  render_map(cr);
  cairo_surface_write_to_png(surface, filename);
  cairo_destroy(cr);
  cairo_surface_destroy(surface);
}
开发者ID:kripton,项目名称:krad_radio-1,代码行数:27,代码来源:kr_map.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cairo_test_log函数代码示例发布时间:2022-05-30
下一篇:
C++ cairo_surface_status函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap