//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e P a g e // //--------------------------------------------------------------------// // // // Write individual test data page sequences to output file. // // // //--------------------------------------------------------------------// private static void generatePage(BinaryWriter prnWriter, Int32 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Int32[] sampleDef, Boolean formAsMacro, UInt16 logXOffset) { Int16 posX, posY, rectX, rectY, rectHeight, rectWidth; Int16 ptSize; Int32 temp; Byte [] palette_0 = new Byte[3], palette_1 = new Byte[3], palette_2 = new Byte[3], palette_3 = new Byte[3]; //----------------------------------------------------------------// if (formAsMacro) { PCLWriter.macroControl(prnWriter, _macroId, PCLWriter.eMacroControl.Call); } else { generateOverlay(prnWriter, false, logXOffset, indxPaperSize, indxOrientation); } rectHeight = (Int16)(_lineInc / 2); rectWidth = _lineInc; //----------------------------------------------------------------// // // // Set pattern transparency to Opaque so that white samples show // // on the shaded background. // // // //----------------------------------------------------------------// PCLWriter.patternTransparency(prnWriter, true); //----------------------------------------------------------------// // // // Colour definitions. // // // //----------------------------------------------------------------// temp = sampleDef [0]; palette_0 [2] = (Byte)(temp & 0xff); temp = temp >> 8; palette_0 [1] = (Byte)(temp & 0xff); temp = temp >> 8; palette_0 [0] = (Byte)(temp & 0xff); temp = sampleDef [1]; palette_1 [2] = (Byte)(temp & 0xff); temp = temp >> 8; palette_1 [1] = (Byte)(temp & 0xff); temp = temp >> 8; palette_1 [0] = (Byte)(temp & 0xff); temp = sampleDef [2]; palette_2 [2] = (Byte)(temp & 0xff); temp = temp >> 8; palette_2 [1] = (Byte)(temp & 0xff); temp = temp >> 8; palette_2 [0] = (Byte)(temp & 0xff); temp = sampleDef [3]; palette_3 [2] = (Byte)(temp & 0xff); temp = temp >> 8; palette_3 [1] = (Byte)(temp & 0xff); temp = temp >> 8; palette_3 [0] = (Byte)(temp & 0xff); //----------------------------------------------------------------// // // // Write details. // // // //----------------------------------------------------------------// ptSize = 12; PCLWriter.font(prnWriter, true, "19U", PCLFonts.getPCLFontSelect(_indxFontCourier, PCLFonts.eVariant.Regular, ptSize, 0)); //----------------------------------------------------------------// posX = (Int16)(_posXDesc4 - logXOffset); posY = _posYDesc4; posX += _incInch; PCLWriter.text(prnWriter, posX, posY, 0, "0x" + palette_0 [0].ToString("x2") + palette_0 [1].ToString("x2") + palette_0 [2].ToString("x2")); posY += _lineInc; PCLWriter.text(prnWriter, posX, posY, 0, "0x" + palette_1 [0].ToString("x2") + palette_1 [1].ToString("x2") + palette_1 [2].ToString("x2")); posY += _lineInc; PCLWriter.text(prnWriter, posX, posY, 0, "0x" + palette_2 [0].ToString("x2") + palette_2 [1].ToString("x2") + palette_2 [2].ToString("x2")); posY += _lineInc; PCLWriter.text(prnWriter, posX, posY, 0, "0x" + palette_3 [0].ToString("x2") + palette_3 [1].ToString("x2") + palette_3 [2].ToString("x2")); //----------------------------------------------------------------// // // // RGB colour space. // // // //----------------------------------------------------------------// PCLWriter.configureImageData(prnWriter, 0, // colour space = RGB 1, // PEM = Direct-by-pixel 2, // 2 bitsPerindex -> 4 colours 8, // bits per component - ignored 8, // bits per component - ignored 8); // bits per component - ignored PCLWriter.paletteEntry(prnWriter, 0, palette_0 [0], palette_0 [1], palette_0 [2]); PCLWriter.paletteEntry(prnWriter, 1, palette_1 [0], palette_1 [1], palette_1 [2]); PCLWriter.paletteEntry(prnWriter, 2, palette_2 [0], palette_2 [1], palette_2 [2]); PCLWriter.paletteEntry(prnWriter, 3, palette_3 [0], palette_3 [1], palette_3 [2]); posX = (Int16)(_posXData - logXOffset); posY = _posYData; rectX = posX; rectY = posY; PCLWriter.setForegroundColour(prnWriter, 0); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 1); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 2); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 3); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); //----------------------------------------------------------------// // // // CMY colour space. // // // //----------------------------------------------------------------// PCLWriter.configureImageData(prnWriter, 1, // colour space = CMY 1, // PEM = Direct-by-pixel 2, // 2 bitsPerindex -> 4 colours 8, // bits per component - ignored 8, // bits per component - ignored 8); // bits per component - ignored PCLWriter.paletteEntry(prnWriter, 0, palette_0[0], palette_0[1], palette_0[2]); PCLWriter.paletteEntry(prnWriter, 1, palette_1[0], palette_1[1], palette_1[2]); PCLWriter.paletteEntry(prnWriter, 2, palette_2[0], palette_2[1], palette_2[2]); PCLWriter.paletteEntry(prnWriter, 3, palette_3[0], palette_3[1], palette_3[2]); posX += _colInc; rectX = posX; rectY = posY; PCLWriter.setForegroundColour(prnWriter, 0); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 1); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 2); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 3); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); //----------------------------------------------------------------// // // // SRGB colour space. // // // //----------------------------------------------------------------// PCLWriter.configureImageData(prnWriter, 2, // colour space = SRGB 1, // PEM = Direct-by-pixel 2, // 2 bitsPerindex -> 4 colours 8, // bits per component - ignored 8, // bits per component - ignored 8); // bits per component - ignored PCLWriter.paletteEntry(prnWriter, 0, palette_0[0], palette_0[1], palette_0[2]); PCLWriter.paletteEntry(prnWriter, 1, palette_1[0], palette_1[1], palette_1[2]); PCLWriter.paletteEntry(prnWriter, 2, palette_2[0], palette_2[1], palette_2[2]); PCLWriter.paletteEntry(prnWriter, 3, palette_3[0], palette_3[1], palette_3[2]); posX += _colInc; rectX = posX; rectY = posY; PCLWriter.setForegroundColour(prnWriter, 0); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 1); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 2); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); rectY += _lineInc; PCLWriter.setForegroundColour(prnWriter, 3); PCLWriter.rectangleSolid(prnWriter, rectX, rectY, rectHeight, rectWidth, false, false, false); //----------------------------------------------------------------// PCLWriter.formFeed(prnWriter); }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e I m a g e H e a d e r // //--------------------------------------------------------------------// // // // Write image initialisation sequences to output file. // // // //--------------------------------------------------------------------// private static void generateImageHeader(BinaryWriter prnWriter, UInt16 srcBitsPerPixel, Int32 srcWidth, Int32 srcHeight, Int32 srcResX, Int32 srcResY, Single destPosX, Single destPosY, Int32 destScalePercentX, Int32 destScalePercentY, Int32 rasterResolution, UInt32 srcPaletteEntries, Boolean srcBlackWhite) { Int16 coordX, coordY; UInt32 paletteEntries = 0; Byte bitsPerIndex = 0x00; Boolean indexed = true; //----------------------------------------------------------------// // // // Set position. // // // //----------------------------------------------------------------// coordX = (Int16)(destPosX * 600); coordY = (Int16)(destPosY * 600); PCLWriter.palettePushPop(prnWriter, PCLWriter.ePushPop.Push); PCLWriter.cursorPosition(prnWriter, coordX, coordY); //----------------------------------------------------------------// // // // Set colour space, etc. // // // // Note that we only support the following bitmap types: // // // // - 1-bit black and white: // // Colour space: Gray (1 plane) // // Encoding: indirect-pixel // // Palette: elements = 2 (= 2^1) // // planes = 1 // // length = 2 (= 2 * 1) bytes. // // Image data: Each image pixel is defined by 1 bit // // which is used an an index into the // // 2-element palette. // // // // - 1-bit colour // // Colour space: RGB (3 plane) // // Encoding: indirect-pixel // // Palette: elements = 2 (= 2^1) // // planes = 3 // // length = 6 (= 2 * 3) bytes. // // Image data: Each image pixel is defined by 1 bit // // which is used an an index into the // // 2-element palette. // // // // - 4-bit: // // Colour space: RGB (3-plane) // // Encoding: indirect-pixel // // Palette: elements = 16 (= 2^4) // // planes = 3 // // length = 48 (= 16 * 3) bytes. // // Image data: Each group of 4 bits defines an image // // pixel by use as an index into the // // 16-element palette. // // // // - 24-bit: // // Colour space: RGB (3-plane) // // Encoding: direct-pixel // // Palette: none // // Image data: Each group of 24 bits defines an image // // pixel as three 8-bit values, directly // // specifying the RGB values. // // // //----------------------------------------------------------------// if (srcBlackWhite) { indexed = true; bitsPerIndex = 0x01; paletteEntries = 0; } else if (srcBitsPerPixel == 1) { indexed = true; bitsPerIndex = 0x01; // paletteEntries = 0x00000001 << 1; paletteEntries = srcPaletteEntries; } else if (srcBitsPerPixel == 4) { indexed = true; bitsPerIndex = 0x04; // paletteEntries = 0x00000001 << 4; paletteEntries = srcPaletteEntries; } else if (srcBitsPerPixel == 24) { indexed = false; bitsPerIndex = 0x00; paletteEntries = 0; } if (srcBlackWhite) { PCLWriter.paletteSimple(prnWriter, PCLWriter.eSimplePalette.K); } else { if (indexed) { PCLWriter.configureImageData(prnWriter, 0x02, // ColourSpace = sRGB 0x01, // PEM = Indexed by Pixel bitsPerIndex, 0x00, // Not used 0x00, // Bits per component 0x00); // Bits per component } else { PCLWriter.configureImageData(prnWriter, 0x02, // ColourSpace = sRGB 0x03, // PEM = Direct by Pixel 0x00, // Not used 0x08, // Bits per component 0x08, // Bits per component 0x08); // Bits per component } if (paletteEntries != 0) { Byte red = 0x00, green = 0x00, blue = 0x00; for (Int16 i = 0; i < paletteEntries; i++) { ToolImageBitmapCore.getBmpPaletteEntry(i, ref red, ref green, ref blue); PCLWriter.paletteEntry(prnWriter, i, red, green, blue); } } } //----------------------------------------------------------------// // // // Generate raster definition and start sequences. // // // //----------------------------------------------------------------// PCLWriter.rasterResolution(prnWriter, rasterResolution, true); PCLWriter.rasterBegin(prnWriter, srcWidth, srcHeight, srcResX, srcResY, destScalePercentX, destScalePercentY, 0); }