Author Topic: Barcodes in BGRABitmap  (Read 2377 times)


  • Full Member
  • ***
  • Posts: 154
Barcodes in BGRABitmap
« on: December 05, 2014, 04:18:44 am »
I am having trouble getting a barcode in a TBGRABitmap canvas.

I am using the barcode library.

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
  Bitmap,Photo : TBGRABitmap;
  Barcode : TBarcode;
    Bitmap := TBGRABitmap.Create(661,1028,BGRAPixelTransparent);
     Photo :=TBGRABitmap.Create('somepicture.jpg');
       with Bitmap do begin
         FontStyle:= [fsBold];
         TextOut(240,950,'Name Last Name',BGRABlack,taCenter);
       with Barcode do begin
         Left:=40+((400-Width) div 2);

It works fine in Linux but on Windows the black lines of the barcode are gone, only the white lines show. I have tried drawing a polygon directly to canvas and if I use any color except black it appears fine. Only the black color seems to be causing this problem. What am I missing?


  • Hero Member
  • *****
  • Posts: 3561
    • Personal webpage
Re: Barcodes in BGRABitmap
« Reply #1 on: December 05, 2014, 04:00:31 pm »
The black color (clBlack) is used to specify a transparent color. To have a black color, you need to use clBlackOpaque constant instead.

Alternatively, if you cannot change the color of the bar code, you can use Bitmap.AlphaFill to set the alpha channel to 255 afterwards in the desired area.
Conscience is the debugger of the mind


TinyPortal © 2005-2018