从头开始创建图形,并返回他们打印页面事件 [英] Creating graphics from scratch and returning them to print a page event

查看:76
本文介绍了从头开始创建图形,并返回他们打印页面事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在C#.NET 3.5。我有一个类食谱包含图像和一些字符串。我想打印出这些食谱,百分之四页。我想在课堂上返回的东西吸引到我的打印文档写了一个getprintobject的功能,但我难倒...

I'm working in C# .NET 3.5. I have a class of recipes that contains an image and some strings. I want to print out these recipes, four per page. I want to write a "getprintobject" function in the class to return something to draw onto my print document, but I'm stumped...

我希望我可以创建并返回一个图形对象,但我没有看到一个e.graphics.drawgraphics()。我也想过创建位图或图像并返回了,但我不知道如何建立一个从无到有,得到一个新的图形对象进行修改。

I wish I could just create and return a graphics object, but I don't see a "e.graphics.drawgraphics()". I have also thought about creating a bitmap or image and returning that, but I'm not sure how to create one from scratch and get a new graphics object to modify it.

推荐答案

创建映像,并使用该图像为基础的图形对象。例如,

Create an Image, and use that image as a base for your Graphics object. e.g.

Bitmap img = new Bitmap(50, 50);
Graphics g = Graphics.FromImage(img);

绘制你的图形对象,将借鉴图像 - 然后你就可以返回

Drawing on your graphics object, will draw on your image -- which you can then return.

这篇关于从头开始创建图形,并返回他们打印页面事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆