PCL bitmap color graphics are distorted. Code Included: What Am I Missing?

The function below prints a color bitmap on a PCL-5 printer. The feature was adapted from a 2-color (1bpp) print function, which we worked great except for grainy two-color printing. The problem is that the image comes out with a large black bar running to the right of the image to the edge of the page as follows:

  IMAGE#########################################
  IMAGE#########AREA COMPLETELY BLACK###########
  IMAGE#########################################

The image itself looks perfect, otherwise.

Various PCL-to-PDF tools don’t show an image at all, which makes me believe that I forgot to do something. Corresponding discards (\ u001bE \ u001b% -12345X) were sent before and after it.

Any PCL experts? I have a PCL 5 Technical Color Reference and it got me so far. The last thing that makes me go crazy though.

* Editing: Now I know which command is causing the problem, but I do not know why:

  stream("\u001b*r0F"); 

This should support the rotation of the image along with the page (portrait, landscape). If I remove this, the problem will disappear. I can compensate by rotating the bitmap in advance, but I really want to know what caused this!

   static void PrintImage()
    {
        // Get an image into memory
        Image original = Image.FromFile("c:\\temp\\test.jpg");
        Bitmap newBitmap = new Bitmap(original, original.Width, original.Height);

        stream(String.Format("\u001b*p{0:d}x*p{1:d}Y", 1000, 1000));// Set cursor.
        stream("\u001b*t300R");                                     // 300 DPI
        stream(String.Format("\u001b*r{0:d}T", original.Height));   // Height
        stream(String.Format("\u001b*r{0:d}S", original.Width));    // Width

        stream("\u001b*r3U");      // 8-bit color palette
        stream("\u001b*r0F");      // Follow logical page layout (landscape, portrait, etc..)
        // Set palette depth, 3 bytes per pixel RGB
        stream("\u001b*v6W\u0000\u0003\u0000\u0008\u0008\u0008");  
        stream("\u001b*r1A");      // Start raster graphics
        stream("\u001b*b0M");      // Compression 0 = None, 1 = Run Length Encoding

        // Not fast, but fast enough.  
        List<byte> colors = new List<byte>();
        for (int y2 = 0; y2 < original.Height; y2++)
        {
            colors.Clear();
            for (int x2 = 0; x2 < original.Width; x2++)
            {
                Color c = newBitmap.GetPixel(x2, y2);
                colors.Add(c.R);
                colors.Add(c.G);
                colors.Add(c.B);
            }

            stream(String.Format("\u001b*b{0}W", colors.Count));     // Length of data to send
            streamBytes(colors.ToArray());                           // Binary data
        }
        stream("\u001b*rB");   // End raster graphics  (also tried *rC -- no effect)
    }
+3
source share
1 answer

There are several problems with your code. First of all, your cursor code is incorrect, it should read:

"\u001b*p{0:d}x1:d}Y", 1000, 1000

It means:

<esc>*p1000x1000Y

You had:

<esc>*p1000x*p1000Y

PCL , + + + .. , , PCL.

, (* r3A) , ( , ):

Int32 deciHeight = original.Height / (int)original.HorizontalResolution * 720;
Int32 deciWidth = original.Width / (int)original.VerticalResolution * 720;
stream("\u001b*t{0:d}h{1:d}V", deciHeight, deciWidth));

- ( ) PCL , . ! , wold $89 pclWorks. SDK, PCL. , PCL, .

, - , jpg (original.RotateFlip), .

, , . .

, , PCL , . , ; , , .

+4

All Articles