Maybe that's the bitmap resolution despite how is displayed on canvas.
You must scale it yourself....
I thought
Width and
Height property of barcode object set when barcode is generated.
In
SaveToStream method width and height are set from
Exact_Width and
Exact_Height from rendered symbol.
I found this comment in zint unit:
// added by wp
exact_width: single; // exact width of symbol after rendering. symbol^.width may be wrong...
exact_height: single; // height of symbol after rendering.
If I call
GetPreferredSize method, I seem to get correct width and height.
I tested like this:
procedure CreatePDF417(AText: String);
var barcode: TBarcodePDF417;
bitmap: TBitmap;
msBitmap: TMemoryStream;
w, h: Integer;
r: TRect;
begin
barcode := TBarcodePDF417.Create(nil);
try
barcode.RecommendedSymbolSize := True;
barcode.Text := AText;
WriteLn('Generated barcode width: ', barcode.Width, ', height: ', barcode.Height);
bitmap := TBitmap.Create;
msBitmap := TMemoryStream.Create;
try
barcode.SaveToStream(msBitmap, TBitmap);
msBitmap.Seek(0, soBeginning);
bitmap.LoadFromStream(msBitmap, msBitmap.Size);
WriteLn('BMP from stream width: ', bitmap.Width, ', height: ', bitmap.Height);
finally
msBitmap.Free;
bitmap.Free;
end;
barcode.GetPreferredSize(w, h);
WriteLn('Preffered barcode size width: ', w, ', height: ', h);
barcode.Width := w;
barcode.Height := h;
bitmap := TBitmap.Create;
try
r := Rect(0, 0, barcode.Width, barcode.Height);
bitmap.SetSize(barcode.Width, barcode.Height);
bitmap.Canvas.Brush.Color := clWhite;
bitmap.Canvas.FillRect(r);
barcode.PaintOnCanvas(bitmap.Canvas, r);
WriteLn('BMP from canvas width: ', bitmap.Width, ', height: ', bitmap.Height);
finally
bitmap.Free;
end;
finally
barcode.Free;
end;
end;