P4 Software
/
BarcoderX English
Applies to: BarcoderX Basic and Ultimate
Status: Built, not yet released. The drawing engine exists and is tested. It is a library inside the engine that is still being built. There is no released package, there is no public interface that you can call to draw directly, and the licensed engine will be the only public way to produce output. The engine can fill shapes, draw outlines, blend colors, clip and run a list of drawing steps on three kinds of surface. It cannot yet draw dashed lines or place pictures. This page says what it does today and what comes later.
BarcoderX draws labels with its own drawing engine. It does not use the drawing functions of the operating system, so a label looks the same on Windows x64, Linux x64 and Linux arm64. Everything on a label, such as text, barcodes and boxes, is drawn with the parts described here. This page describes them as far as a developer needs to know. For a label, the engine works out the drawing from the template, so you will not call these parts yourself.
A shape is a path: a series of moves, straight lines and curves. A path can hold several separate pieces, and each piece can be open or closed. A path is built from these steps:
Four ready-made shapes save the steps: a rectangle, a rectangle with rounded corners (each corner has its own horizontal and vertical radius), an ellipse and an arc of an ellipse.
A transform places a shape on the page. A shape can be shifted, scaled by different amounts across and down, and turned by any angle, around the origin or around a point you choose. Transforms combine in the order you give, and a transform that can be undone has an inverse. Turning by an angle that is not a multiple of 90 degrees is drawn directly, and the result is smooth.
Filling works out which pixels the inside of a shape covers, and by how much. Two rules decide what is inside when a path crosses itself or holds a piece inside another piece:
The edges are smooth. For every pixel, the engine works out how much of the pixel the shape covers, as a number from 0 (none) to 255 (all). Putting a color on a surface in that proportion is blending (see below). A pixel that the shape covers completely is exactly 255, and one that it does not touch is exactly 0. A rectangle whose edges lie on pixel boundaries is therefore filled with no soft edge at all.
The outline of a path is drawn by stroking it. A stroke has:
Lines and the outlines of boxes and ellipses are drawn this way. Curves are cut into short straight pieces first, as for a fill. Dashed lines are not built yet.
Drawing with partial transparency puts the new color over what is already there, in proportion to its opacity and to how much of the pixel it covers. Gray surfaces use a fixed weighting of red, green and blue to turn a color into a gray value.
A clip area limits where drawing can reach. It can be a rectangle or a path. Clip areas can be nested, up to 64 at the same time. A drawing that nests more, or whose clip shapes would need too much memory, stops at that point with the code BX3006. Where a clip shape and the edge of another shape cross the same pixel, the result is approximate. A rectangle drawn inside a rectangle clip is exact.
A surface is the grid of pixels that you draw on. Three kinds exist:
| Surface | What it holds |
|---|---|
| Color with transparency | Red, green, blue and opacity for each pixel, 8 bits each. |
| Gray | One 8-bit value for each pixel. |
| Black and white | One bit for each pixel, eight to a byte. |
A new surface starts empty: transparent for color and black for gray.
On a black-and-white surface, nothing is ever gray or smoothed. A shape turns a dot black where it covers at least half of the dot. White paint clears dots. Bars drawn as rectangles on whole dots are exact. A thin line that is centered on a whole dot can come out one dot wider than you expect, because exactly half coverage counts as black. A line centered on half a dot, or drawn as a rectangle, keeps its width.
Instead of drawing at once, the engine records the steps in a list: fill a path, fill rectangles, stroke a path, start a clip area (a rectangle or a path) and end it. The list can be written out as plain text in one fixed form, so two lists can be compared exactly. Running a list draws it on a surface. If a step fails, the run stops at that step, says which step it was, and keeps what was drawn before it.
BarcoderX checks every limit before it allocates the memory it protects. A drawing that is too large or too complex is refused with a diagnostic code from 3001 to 3006. See Diagnostic codes.
| Limit | Value |
|---|---|
| Pixels in one surface, window or coverage area | 64,000,000 (64 million) |
| Longest side of a surface, window or coverage area | 262,144 pixels. This is a fixed property of the design and cannot be raised. |
| Steps in one path | 1,000,000 |
| Straight pieces that the curves of one fill are cut into | 4,000,000 |
| Work for one fill, one outline or one run of a list | 100,000,000 units. Depending on the work, that is between about 2 and about 8 seconds on a recent desktop processor. |
| Size of a coordinate after the transform | About one billion pixels (2 to the power 30) |
| Clip areas open at the same time | 64. The memory kept for clip shapes never goes above the pixel limit of a surface. |
| Steps in the outline of one stroke | 500,000 |
| Steps in the outlines of all the strokes of one list | 2,000,000 |
The limits on straight pieces and on work, and the last three limits, are first choices that the builders made. They have not been confirmed yet and can change before the first release. A host can lower the limits.
The drawing code checks for cancellation at every row and at every 1,024 pieces, so the program that calls it can enforce its own time limit, such as 2 seconds for one label. A coordinate that is not a number, or is too large, is refused.
BarcoderX is a product of P4 Software.
Was this page helpful?