It is a single .prg and may be too large to post but I'm going to try anyway and see what happens.
Código: Selecionar todos
Printer = "LPT1"
BitmapF = "DORLetterHead.BMP"
Pixels = " "
DecBMP(BitmapF, @Pixels)
Set Printer to &Port
Set _SET_PRINTER to .t.
PrintBMP(BitmapF, Pixels, 00, 00)
Eject
Break
********************************************************
Function PrintBMP
Parameter BitmapF, Pixels, Filas_, Columnas_
* Programado por Diego D'Onofrio * Email: near@lycos.com
********************************************************
Pixels = Iif(Pixels == Nil, " ", Pixels)
Filas_ = Iif(Filas_ == Nil, 0, Filas_)
Columnas_ = Iif(Columnas_ == Nil, 0, Columnas_)
P1_ = 0
P2_ = 0
P3_ = 300
P4_ = .F.
Exit = set(17, .F.)
P11_ = Len(Pixels) - 1
P12_ = Len(Pixels[1]) + Iif(P4_, 2, 0)
P6_ = Pixels[P11_ + 1]
If (P3_ == 0 .AND. P1_ == 0 .AND. P2_ == 0)
P3_ = Iif(P6_ == 1, 150, 300)
EndI
If (P3_ == 0)
P3_ = AjustTam(P12_ * 8, P11_ + Iif(P4_, 16, 0), P1_, P2_)
EndI
P3_ = Iif(!(P3_ == 75) .AND. !(P3_ == 100) .AND. !(P3_ == ;
150) .AND. !(P3_ == 300) .AND. !(P3_ == 600), 75, P3_)
PosiTemp = Filas_
PosiTemp = PosiTemp - 0.25
PosiTemp = Iif(PosiTemp < 0, 0, PosiTemp)
Filas_ = Int(PosiTemp * 300)
PosiTemp = Columnas_
PosiTemp = PosiTemp - 0.50
PosiTemp = Iif(PosiTemp < 0, 0, PosiTemp)
Columnas_ = Int(PosiTemp * 300)
P13_ = AllTrim(Tran(Filas_, "9999999999"))
P14_ = AllTrim(Tran(Columnas_, "9999999999"))
P15_ = AllTrim(Tran(P3_, "9999"))
P16_ = AllTrim(Tran(P12_, "9999999999"))
qqOut(Chr(27) + "*p" + P13_ + "x" + P14_ + "Y")
qqOut(Chr(27) + "*t" + P15_ + "R")
qqOut(Chr(27) + "*r0F")
qqOut(Chr(27) + "*r1A")
If P4_
For P10_ = 1 To 8
qqOut(Chr(27) + "*b0m" + P16_ + "W" + Iif(P10_ <= 2, ;
Repl("ÿ", P12_), "À" + Repl(Chr(0), P12_ - 2) + Chr(03)))
Next
EndI
PosiTemp = 0
Pix2 = " "
P5_ = (" ", " ", " ", " ")
For P10_ = P11_ To 1 Step -1
If (P6_ == 1)
qqOut(Chr(27) + "*b0m" + P16_ + "W" + Iif(P4_, "À", "") ;
+ Pixels[P10_] + Iif(P4_, Chr(03), ""))
Else
If (!(Pixels[P10_] == Pix2))
BITConvert(Pixels[P10_], @P5_)
EndI
Pix2 = Pixels[P10_]
For Loop1 = 1 To 4
P16_ = AllTrim(Tran(Len(P5_[Loop1]) + ;
Iif(P4_, 2, 0), "999999"))
qqOut(Chr(27) + "*b0m" + P16_ + "W" + Iif(P4_, "À", ;
"") + P5_[Loop1] + Iif(P4_, Chr(03), ""))
Next
EndI
Next
If P4_
For P10_ = 1 To 8
qqOut(Chr(27) + "*b0m" + P16_ + "W" + Iif(P10_ > 6, ;
Repl("ÿ", P12_), "À" + Repl(Chr(0), P12_ - 2) + Chr(03)))
Next
EndI
qqOut(Chr(27) + "*rB")
Set 17 to Exit
Return 0
********************************************************
Function DecBMP
Parameter BitmapF, Pixels
* Programado por Diego D'Onofrio * Email: near@lycos.com
********************************************************
BitmapF = Uppe(AllTrim(BitmapF))
ManeArch = FOpen(BitmapF)
If (FError() != 0)
FClose(ManeArch)
Return
EndI
Cadena = FReadStr(ManeArch, 2)
If (!(Cadena == "BM"))
FClose(ManeArch)
Return
EndI
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BmpLay = bin2l(Cadena)
FSeek(ManeArch, 4, 1)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BuscaB_ = bin2l(Cadena)
Cadena = Spac(2)
FRead(ManeArch, @Cadena, 2)
Cadena = Cadena + Chr(0) + Chr(0)
FSeek(ManeArch, 2, 1)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
P2_ = bin2l(Cadena)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
TLargo = bin2l(Cadena)
Cadena = Spac(2)
FRead(ManeArch, @Cadena, 2)
Cadena = Cadena + Chr(0) + Chr(0)
BmpLay = bin2l(Cadena)
If (BmpLay != 1)
FClose(ManeArch)
Return
EndI
Cadena = Spac(2)
FRead(ManeArch, @Cadena, 2)
Cadena = Cadena + Chr(0) + Chr(0)
P1_ = bin2l(Cadena)
If (P1_ != 1 .AND. P1_ != 4)
FClose(ManeArch)
Return
EndI
If (P2_ * P1_ > 2000)
FClose(ManeArch)
Return
EndI
Cadena = Spac(2)
FRead(ManeArch, @Cadena, 2)
Cadena = Cadena + Chr(0) + Chr(0)
BmpLay = bin2l(Cadena)
If (BmpLay != 0)
FClose(ManeArch)
Return
EndI
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BmpLay = bin2l(Cadena)
FSeek(ManeArch, 4, 1)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BmpLay = bin2l(Cadena)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BmpLay = bin2l(Cadena)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BmpLay = bin2l(Cadena)
Cadena = Spac(4)
FRead(ManeArch, @Cadena, 4)
BmpLay = bin2l(Cadena)
FSeek(ManeArch, BuscaB_, 0)
Pixels = ""
Cadena = ""
BmpLay = P2_ / IIf(P1_ == 1, 32, 16)
If (!(Int(BmpLay) == BmpLay))
P3_ = (Int(BmpLay) + 1) * IIf(P1_ == 1, 32, 16)
EndI
BmpLay = 0
For Loop = 1 To TLargo
P4_ = Spac(P3_ / IIf(P1_ == 1, 8, 2))
FRead(ManeArch, @P4_, P3_ / IIf(P1_ == 1, 8, 2))
If (P1_ == 1)
FragBMP = BMP2cConv(P4_, P2_)
Else
FragBMP = BMP16cConv(P4_, P2_)
EndI
AAdd(Pixels, FragBMP)
Next
AAdd(Pixels, P1_)
FClose(ManeArch)
Return
********************************************************
Function BITConvert
Parameter Pixels, exit
* Programado por Diego D'Onofrio * Email: near@lycos.com
********************************************************
Bit2Conv = (("F", "F", "F", "F"), ("F", "E", "7", "F"), ("F", -
"E", "7", "B"), ("D", "E", "7", "B"), ("D", "E", "6", "B"), -
("D", "6", "6", "B"), ("D", "6", "6", "9"), ("9", "6", "6", -
"9"), ("9", "4", "6", "9"), ("9", "4", "2", "9"), ("9", -
"4", "0", "9"), ("9", "0", "0", "9"), ("9", "0", "0", "1"), -
("8", "0", "0", "1"), ("8", "0", "0", "0"), ("0", "0", "0", -
"0"))
Largo = Len(Pixels)
Exit= ("", "", "", "")
For Loop = 1 To Largo
P2_= NToc(Asc(SubStr(Pixels, Loop, 1)), 16, 2, "0")
For Loop4 = 1 To 4
P1_ = Bit2Conv[cton(Left(P2_, 1), 16) + 1][Loop4] + ;
Bit2Conv[cton(right(P2_, 1), 16) + 1][Loop4]
Exit[Loop4]= Exit[Loop4] + Chr(cton(P1_, 16))
Next
Next
Return
********************************************************
Function AjustTam
Parameter Param1, Param2, Param3, Param4
* Programado por Diego D'Onofrio * Email: near@lycos.com
********************************************************
Res = 75
If (Param1 / Res <= Param3 .AND. Param2 / Res <= Param4)
Return Res
EndI
Res = 100
If (Param1 / Res <= Param3 .AND. Param2 / Res <= Param4)
Return Res
EndI
Res = 150
If (Param1 / Res <= Param3 .AND. Param2 / Res <= Param4)
Return Res
EndI
Res = 300
If (Param1 / Res <= Param3 .AND. Param2 / Res <= Param4)
Return Res
EndI
Retu 600
********************************************************
Function BMP16cConv
Parameter Byte1, Byte2
* Programado por Diego D'Onofrio * Email: near@lycos.com
********************************************************
If (Len(Byte1) > Byte2 / 2)
P2_ = Int(Byte2 / 2)
If (P2_ * 2 < Byte2)
P2_++
EndIf
Byte1 = Left(Byte1, P2_)
If (P2_ * 2 > Byte2)
P1_ = right(Byte1, 1)
Byte1 = Left(Byte1, Len(Byte1) - 1)
P3_ = NToc(Asc(P1_), 16, 2, "0")
P3_ = Left(P3_, 1) + "F"
P1_ = Chr(cton(P3_, 16))
Byte1 = Byte1 + P1_
EndI
EndI
Return Byte1
Here are some errors that I'm getting also......
Compiling IMPRBMP.PRG
line 3: operand expected
Pixels = ()
^
line 7: SET not recognized
Set(_SET_PRINTER, .t.)
^
line 17: operand expected
Pixels = Iif(Pixels == Nil, (), Pixels)
^
line 17: unbalanced parenthesis
Pixels = Iif(Pixels == Nil, ()
^
line 60: unbalanced parenthesis
P5_ = ("", "", "", "")
^
line 85: SET not recognized
Set(17, Exit)
^
line 97: no return value
Return
^
line 102: no return value
Return
^
line 127: no return value
Return
^
line 135: no return value
Return
^
line 139: no return value
Return
^
line 147: no return value
Return
^
line 166: operand expected
Pixels = ()
^
line 185: no return value
Return
^
line 192: unbalanced parenthesis
Bit2Conv = (("F", "F", "F", "F"), ("F", "E", "7", "F"), ("F", ;
^
line 192: unbalanced parenthesis
Bit2Conv = (("F"
^
line 193: verb not recognized
"E", "7", "B"), ("D", "E", "7", "B"), ("D", "E", "6", "B"), ;
^
line 194: verb not recognized
("D", "6", "6", "B"), ("D", "6", "6", "9"), ("9", "6", "6", ;
^
line 195: verb not recognized
"9"), ("9", "4", "6", "9"), ("9", "4", "2", "9"), ("9", ;
^
line 196: verb not recognized
"4", "0", "9"), ("9", "0", "0", "9"), ("9", "0", "0", "1"), ;
^
line 197: verb not recognized
("8", "0", "0", "1"), ("8", "0", "0", "0"), ("0", "0", "0", ;
^
line 198: verb not recognized
"0"))
^
line 200: unbalanced parenthesis
Exit= ("", "", "", "")
^
line 206: rest of line ignored
Exit[Loop4]= Exit[Loop4] + Chr(cton(P1_, 16))
^
line 209: no return value
Return
^
line 242: ASSIGNMENT error
P2_++
^
26 errors
Code Pass 1
Code Pass 2
Code size 3122, Symbols 1136, Constants 398