C# Programming
06-26-2009, 03:21 PM
Hi all,
I have a printing functions in my C# WinForms (.Net 3.5) application that prints to a printer that supports colour printing.
I am using a custom class that inherits from PrintDocument.
My printed page contains an image and some text. The Image contains colour.
Now, I can print everything just the way I want it to look in colour. But I want to include an option to print in 'Black and White'.
I can handle the text fine as I can just change the colour, but the image is where I am having issues.
I have already tried to set the DefaultPageSettings.Color property to false, this does not work, thou I suspect that is because I am inheriting the PrintDocument class and am expected to handle this functionality myself.
EDIT: I just realised that I am not handling the ability for multiple copies manually but when I set in DefaultPageSettings then it is auto handled as expected so I am now thinking that they is something causing the Color property to not be applied automatically.
I also tried creating a Bitmap with a grayscale pixelformat and drawing the image to that before drawing that bitmap the the PrintDocument's Graphics - This spat out a 'Out Of Memory' exception (admittedly, I could have made an error in the code but I don't really want to take this option anyway if possible)
A third option, which I have not tried yet, is to loop the image's pixels and convert them to grayscale - which is easy enough but again I would rather avoid that effort is possible.
Can anybody recommend the best way to handle this?
Thanks for any answers contributed
Life goes very fast. Tomorrow, today is already yesterday.
I have a printing functions in my C# WinForms (.Net 3.5) application that prints to a printer that supports colour printing.
I am using a custom class that inherits from PrintDocument.
My printed page contains an image and some text. The Image contains colour.
Now, I can print everything just the way I want it to look in colour. But I want to include an option to print in 'Black and White'.
I can handle the text fine as I can just change the colour, but the image is where I am having issues.
I have already tried to set the DefaultPageSettings.Color property to false, this does not work, thou I suspect that is because I am inheriting the PrintDocument class and am expected to handle this functionality myself.
EDIT: I just realised that I am not handling the ability for multiple copies manually but when I set in DefaultPageSettings then it is auto handled as expected so I am now thinking that they is something causing the Color property to not be applied automatically.
I also tried creating a Bitmap with a grayscale pixelformat and drawing the image to that before drawing that bitmap the the PrintDocument's Graphics - This spat out a 'Out Of Memory' exception (admittedly, I could have made an error in the code but I don't really want to take this option anyway if possible)
A third option, which I have not tried yet, is to loop the image's pixels and convert them to grayscale - which is easy enough but again I would rather avoid that effort is possible.
Can anybody recommend the best way to handle this?
Thanks for any answers contributed
Life goes very fast. Tomorrow, today is already yesterday.