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:
IMAGEAREA COMPLETELY BLACK
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()
{
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));
stream("\u001b*t300R");
stream(String.Format("\u001b*r{0:d}T", original.Height));
stream(String.Format("\u001b*r{0:d}S", original.Width));
stream("\u001b*r3U");
stream("\u001b*r0F");
stream("\u001b*v6W\u0000\u0003\u0000\u0008\u0008\u0008");
stream("\u001b*r1A");
stream("\u001b*b0M");
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));
streamBytes(colors.ToArray());
}
stream("\u001b*rB");
}
source
share