Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Tamila  
#1 Posted : Friday, July 11, 2008 3:56:10 PM(UTC)
Tamila

Rank: Advanced Member

Groups:
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Overview

Some of our customers concern about high-quality printing. This question is very popular among our clients who use Graphics Mill for pre-print operations.
This article describes the basic approach how to print images without color loss.

Reason

Using Graphics Mill (and .NET Framework) you may do print through Windows API using PrintDocument class, which means that you cannot send to printer raw CMYK pixel data, it is limitation of the Microsoft platform. There will be always extra RGB to CMYK conversion.
In this case you perform color transformation twice:
  1. First transformation - when you convert bitmap from color profile associated with original bitmap to another RGB profile of virtual printer device (DC). You have to perform this conversion because Windows supports RGB format for virtual printer devices only. You need to do this operation in your software using Graphics Mill.
  2. Second transformation - after you draw converted RGB data to virtual printer device, Windows automatically converts your pixels from RGB of virtual printer device to real color space of printer (as usual CMYK, or other color space if more than 4 inks are used). This conversion can be properly done only if this CMYK profile is associated with printer in the printer settings.
Resolution

So if you want to print high-quality outputs you need to do it with color management:
  1. Make sure whether proper color profile is specified for the printer in printer settings in the Windows.
  2. Conversion should be made in PrintDocument.OnPrintPage event handler.
  3. Proper conversion with color management means that you should make sure that:

    a. Bitmap has color profile attached.

    b. Color management engine has output RGB profile set to the same color profile as virtual printer device you draw this bitmap to. To get this profile use ColorProfile.FromHdc method.

    c. Color management is enabled. To make it closer to photoshop, I think it makes sense to use Adobe engine instead of LittleCMS (which is available since version 5.0).

    d. If necessary, adjust color transformation intent.
You can see how to implement this method in following code sample:
Code:

Aurigma.GraphicsMill.Bitmap bmp;
private void button1_Click(object sender, EventArgs e)
{
    //Create Bitmap
    bmp = new Aurigma.GraphicsMill.Bitmap("D:/test/Cmyk32.jpg");
                     
   PrintDocument pd = new PrintDocument();
   pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
   pd.Print();

}
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
     using (Aurigma.GraphicsMill.Bitmap transformedBmp = new
          Aurigma.GraphicsMill.Bitmap())
     {
          using (Aurigma.GraphicsMill.Transforms.PixelFormatConverter pfc = new 
                 Aurigma.GraphicsMill.Transforms.PixelFormatConverter())
          {
              //Color management applying while transform
              pfc.DestinationPixelFormat =
                   Aurigma.GraphicsMill.PixelFormat.Format24bppRgb;
              pfc.ColorManagementEngine =
                   Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms;
              pfc.TransformationIntent =
                   Aurigma.GraphicsMill.Transforms.ColorTransformationIntent.Perceptual;
              IntPtr hdc = ev.Graphics.GetHdc();
              try
              {
                 //Get HDC color profile
                 pfc.RgbColorProfile = ColorProfile.FromHdc(hdc);
              }
              finally
              {
                  ev.Graphics.ReleaseHdc();
              }
              pfc.ApplyTransform(bmp, transformedBmp);
              transformedBmp.Draw(ev.Graphics, 0, 0, 
                   Aurigma.GraphicsMill.Transforms.CombineMode.Copy);
           }
     }          
}

See also:
  • Convert bitmap to 24-bit RGB (using Convert method).
  • Draw converted bitmap on HDC of the printer.
Conversion from HDC profile to actual printer CMYK profile will be done by Windows automatically.

Edited by moderator Monday, May 28, 2012 8:36:55 PM(UTC)  | Reason: Not specified

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.