Skip to content
P4 Software P4 Software / BarcoderX English

Add these docs to Claude

Ask Claude questions about these docs. Claude reads the published pages and links you back to them. Copy this address:

https://p4-software.opendocs.page/mcp

In claude.ai or Claude Desktop: open Settings, then Connectors, choose Add custom connector and paste the address.

In Claude Code, run:

claude mcp add --transport http docs https://p4-software.opendocs.page/mcp

PNG output

PNG output

Applies to: BarcoderX Basic and Ultimate

Status: Built, not yet released. The PNG writer, and the PNG renderer that draws the result of the label engine and saves it as a PNG file, exist and are tested, but nothing is released yet and there is nothing to download. They are libraries inside the engine that is still being built. There is no released package, and the licensed engine will be the only public way to produce output. The PNG writer cannot be called on its own. The PNG renderer takes only the result of the label engine, and the label service runs the engine and the renderer together: see The label service. This page says what is built and what is not.

PNG is the picture format BarcoderX uses for previews, web pages and any other use where you need a picture of a label. See Output formats for the other formats. This page describes two parts. The first is the PNG renderer, which draws a label and saves it as a PNG file. The second is the PNG writer itself: the part that takes the pixels of a picture and writes a valid PNG file.

BarcoderX writes the PNG file with its own code. The only part it takes from .NET is the compression of the picture data.

Drawing a label and saving it as a PNG file

Between the label engine and the PNG writer there is the PNG renderer. It draws the list of drawing steps of one label on a surface and saves the surface as a PNG file. See The label engine for the list of drawing steps and Drawing shapes for the surfaces. You give it the whole result of the label engine, the kind of picture you want and a time limit. The limits are set when the renderer is created. It gives back the PNG file, or messages that say why there is none. It accepts nothing else: the list of drawing steps is not public, and so no program can draw something that the engine did not make.

Kind of pictureWhat it is for
Black and white, 1 bitWhat a printer would get. There are no grays and no smoothing: a dot is black or white.
GrayA picture in 256 grays.
ColorA preview for a screen. The page is opaque white. A transparent page is planned.
  • The intended pixel size is recorded in the file. You give a resolution in dots per inch, and the file stores it as pixels per meter, the unit of the PNG standard, so a program can show the picture at its intended size.
  • A drawing that cannot be made is refused with a message that says what to change. The cases are a request that cannot be used, a label with no valid size, a label with too many dots, a side that is too long, a resolution that is not valid, a kind of picture that does not exist, a file that would be too large, too many labels at once, and an unexpected problem (BX3700 to BX3708). See Diagnostic codes.
  • Nothing partial is ever returned. A refused or failed drawing gives no picture at all, so a half-drawn barcode can never reach a printer.
  • The same request gives the same file. In BarcoderX's automatic tests, the PNG file of one test label in each of the three kinds of picture has the same fingerprint on Windows x64, Linux x64 and Linux arm64. The caution in "The same file on every platform, and what to compare" below applies to it as well.

Limits when drawing a label

BarcoderX checks every limit before it spends the resource it protects. The program that uses the renderer sets every limit when it creates it. None has a default that the renderer would use behind the program's back, and a limit that cannot be used is refused with BX3700 at the first drawing. A label never sets its own limits.

LimitSet by the programHighest the renderer accepts
Pixels of a black-and-white picture, of a gray picture and of a color pictureThree figures256,000,000 each
Longest side of a surfaceThe drawing limits of the label262,144 pixels
Path segments in one pathThe drawing limits of the label4,000,000
Size of one PNG fileOne figure2,000,000,000 bytes
ResolutionA lowest and a highestNone above what the engine draws (96 to 1,200 dots per inch)
Labels drawn at the same timeOne number, at least 1None

The other drawing limits are the ones on Drawing shapes. The label service sets these figures from its settings file: see The label service. The highest values are the figures that the plan sets for the output of a whole job, 256 MB and 2 GB, applied to one file. A single label should in practice have a much lower limit, and there is no figure for one label yet. How the job figures are applied to one file is a first choice that the builders made (builder's choice, owner confirmation pending). It has not been confirmed yet and can change before the first release.

When a program is already drawing the number of labels it allows, the next one is refused at once with BX3707 and is not queued. A program can work out how many labels it can draw at once from its memory and from the limits. With the limits proposed for a public demo page (see The label engine), one color label is estimated to need about 135 MB. About 88 MB were measured.

What a program that hosts this must do

  • Pass a time limit to every render. The drawing and the saving can each take time, and a limit on size alone does not bound it. The renderer stops when the limit passes and gives back no picture. In a security review, saving an empty color label of 9 megapixels took about 1.5 seconds, and one of 64 megapixels about 11 seconds. A public page should use lower limits, and it needs a limit on how often each client may ask.
  • Cap how many labels are drawn at once, as above, and keep the limits fixed in the program. Do not read them from a template or from a visitor's request.
  • Use the whole result of the engine. The renderer accepts only a label that the engine made without failing. Report the messages of the engine when the engine failed, and do not call the renderer.

What goes in for the PNG writer

You give the writer the pixels of a picture, its width and height, and which kind of pixels they are. These kinds are accepted:

Kind of pictureWhat each pixel holds
Color with transparencyRed, green, blue and opacity, 8 bits each. Opacity is "straight": the color is not already multiplied by it. If your pixels are premultiplied, convert them first.
ColorRed, green and blue, 8 bits each.
GrayOne 8-bit value, 0 is black.
Black and white, 1 bitEight pixels to a byte, the leftmost pixel in the highest bit, each row padded to a whole byte. You can give it in either of two conventions: where 1 means black (the convention of a label bitmap), or where 1 means white (the convention of PNG itself). The file always follows the PNG convention.
PaletteAn 8-bit number for each pixel that points into a palette of 1 to 256 colors. Each palette color can have its own opacity. The writer stores the numbers at the smallest size that holds the palette: 1, 2, 4 or 8 bits.

What comes out

  • A normal PNG file that any viewer opens.
  • The file can record the intended pixel size. You give a resolution in dots per inch, and the file stores it as pixels per meter, the unit of the PNG standard (section 11.3.5.3), so a program that prints it can work out its size. If you give no resolution, the file records none.
  • You can choose the compression level, from 0 (stored, not compressed) to 9 (smallest). The default is 6.
  • You can choose how the rows of the picture are prepared before compression, or leave it on the automatic choice. The automatic choice follows the method that the PNG standard recommends.
  • Files are not interlaced.

Limits of the PNG writer

BarcoderX checks every limit before it allocates any memory, so a picture that is too large is refused at once, not after the computer has run out of memory.

LimitValue
Pixels in one picture64,000,000 (64 million) by default. The program that calls the writer can set a different limit.
Width and heightAt least 1 and at most 2,147,483,647 each, as the PNG standard requires. The pixel limit is reached long before that.
Palette1 to 256 colors. A palette is allowed only with palette pictures, and every pixel must point to a color that is in it.
ResolutionA positive, finite number of dots per inch.
Length of the pixel dataMust match the width, height and kind of picture exactly.

A picture that breaks a limit is not written. The writer reports a clear reason, with a diagnostic code from 3100 to 3106. See Diagnostic codes. A running job can also be canceled between rows.

The same file on every platform, and what to compare

In BarcoderX's automatic tests, the PNG files for ten test cases are identical, byte for byte, on Windows x64, Linux x64 and Linux arm64. The cases use six pictures, five small ones and one of about 600 KB before compression, some of them at several compression levels.

Read this with care:

  • This was measured on one .NET release, not promised. The compression is done by .NET itself, and Microsoft does not promise that two .NET releases, or two kinds of processor, compress the same picture to the same bytes.
  • After a .NET update, the bytes of a PNG file can therefore change even though the picture has not. BarcoderX's code is the same, and the pixels in the file are the same.
  • To check that two files show the same picture, compare their pixels, not their bytes or a hash of the file. Open both, compare the decoded pixels, and treat them as equal if the pixels are equal.

The part that BarcoderX writes itself, the prepared rows before compression, is tested on every platform and does not depend on .NET.

What is not built yet

  • Reading PNG files. The writer only writes.
  • A PNG file for a stored template, for several labels at once, and for data merged into a template. The label service draws one label from one template. See The label service.
  • A transparent page for color pictures. The page is white.
  • Other pixel formats from a label, such as a palette picture. The part that draws a label saves black and white, gray and color.
  • Interlaced PNG and other chunks such as text comments or color profiles.

BarcoderX is a product of P4 Software.

Was this page helpful?