-2

Ok guys. After some time i have maded procedure which works. Here is delphi code:

    procedure TNativePrint.DoPrintBitmap(const ABitmap : TBitmap; const BitsPerSlice : byte);
const
  Threshhold = 127;
type
  TBitArray = array of boolean;
  TRGBTripleArray = ARRAY[Word] of TRGBTriple;
  pRGBTripleArray = ^TRGBTripleArray; // Use a PByteArray for pf8bit color.
var
  vCol : integer;
  vRow : integer;
  vIndex : integer;
  vSliceIndex : integer;
  vBytePos : integer;
  vBitPos : integer;
  vOffset : integer;
  vLuminance : integer;
  vLine: pRGBTripleArray;
  vPixel: TRGBTriple;
  vDots: TBitArray;
  vSlice : byte;
  vBit : byte;
  vTmpBit: byte;
  vVal: boolean;
  vTempStr : string;
begin
  if not Assigned(ABitmap) then exit;

  try
    ABitmap.PixelFormat := pf24bit;
    SetLength(vDots, (ABitmap.Height * ABitmap.Width));
    vIndex := 0;

    for vRow := 0 to ABitmap.Height-1 do begin
      vLine := ABitmap.Scanline[vRow];
      for vCol := 0 to ABitmap.Width-1 do begin
        vPixel := vLine[vCol];
        vLuminance := Trunc((vPixel.rgbtRed * 0.3) + (vPixel.rgbtGreen * 0.59) + (vPixel.rgbtBlue * 0.11));
        vDots[vIndex] := (vLuminance < Threshhold);
        inc(vIndex);
      end;
    end;

    DoSetLineSpacing(24);
    DoAddLine(' ');

    vOffset := 0;
    while (vOffset < ABitmap.Height) do begin
      DoAddLine(#$1B'*'#33+AnsiChar(Lo(ABitmap.Width))+AnsiChar(Hi(ABitmap.Width)), false);

      vTempStr := '';
      for vCol := 0 to ABitmap.Width-1 do begin
        for vSliceIndex := 0 to 2 do begin
          vSlice := 0;
          for vBit := 0 to 7 do begin
            vBytePos := (((vOffset div 8) + vSliceIndex) * 8) + vBit;
            vBitPos := (vBytePos * ABitmap.Width) + vCol;

            vVal := false;
            if (vBitPos < Length(vDots)) then begin
              vVal := vDots[vBitPos];
            end;

            vTmpBit := iff(vVal, 1, 0);
            vSlice := vSlice or (vTmpBit shl (7 - vBit));
          end;

          vTempStr := vTempStr + AnsiChar(vSlice);
        end;
      end;

      inc(vOffset, 24);
      DoAddLine(vTempStr);
    end;

    DoSetLineSpacing(0);
    DoAddLine(' ');
  finally
     vDots := nil;
  end;
end;

Image printed, but as you can see on my Picture, after each line i have free space. As you can see in source, before print image i'm setting linespacing to 24, but it's not help. Can somebody explain how to fix it?

Yevhen
  • 791
  • 9
  • 24

2 Answers2

0

The solution is printout image in page mode: Enable page mode using ESC'L' command Set print area ESC 'W' xL xH yL yH dxL dxH dyL dyH Printout image using my code from first post

Also this problem is present only on EPSON TM-T88V, on other printer you can printout in standart mode.

Yevhen
  • 791
  • 9
  • 24
0

I just used your code with a few modifications to print bitmaps on Epson ESC printer and worked fine.

1.Remove all free spaces:

DoSetLineSpacing(24);  
DoSetLineSpacing(0); 
DoAddLine(' ');  
DoAddLine(' ');  

2.On

DoAddLine(vTempStr) 

add CRLF(#13#10) to vTempStr string:

DoAddLine(vTempStr+#13#10);

thats it..

ocramot
  • 1,361
  • 28
  • 55