FAQ TBarCode DLL / TBarCode Library
How Can I Obtain an Optimal Bitmap Size (Minimizing Quantization Errors)?
How Can I Obtain an Optimal Bitmap Size (Minimizing Quantization Errors)?
To acquire the optimal bitmap size, ensuring that the bars are aligned accurately to the pixel raster, you can utilize the function BCGetOptimalBitmapSize(). This function calculates the ideal dimensions based on the scale factor and adjusted DPI. Here's a breakdown of the process:
- Utilize the size mode bounding rectangle (default in the library).
- Set the DPI using BCSetDPI.
- Specify the desired height (particularly important for linear codes) in the pRect. The width can be a placeholder value.
- There's a scaling factor that enables adjustment of the target size along the X and Y axes. This factor impacts the module width.
- Proceed to query the optimized total bitmap size by invoking TBarCode Library 11: BCGetOptimalBitmapSize.
- The resultant size is in pixels, with the module width already aligned to the pixel raster to mitigate quantization effects. Additionally, the scaling factors are accounted for. Use this size for BCSaveImage(..) or BitmapToFile(..).
- For custom drawing (BCDrawCB), you'll need to convert the returned pixel values to 0.001 [mm]. If your drawing library operates in pixels, ensure conversion back to pixels while considering the DPI.