从头开始创建图形,并返回他们打印页面事件 [英] Creating graphics from scratch and returning them to print a page event
问题描述
我的工作在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屋!