开发者

Creating graphics from scratch and returning them to print a page event

开发者 https://www.devze.com 2023-02-10 09:40 出处:网络
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 c

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...

I wish I could just create and return a graphics object, but I don't see a "e.graphics.drawgraphics()". I hav开发者_StackOverflowe 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消