Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Graphic file
Message
 
To
15/09/2006 04:56:47
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Title:
Environment versions
Visual FoxPro:
FoxPro Dos
OS:
Windows XP SP2
Network:
Novell 4.x
Miscellaneous
Thread ID:
01153997
Message ID:
01154004
Views:
10
Hi,

>How can print inside FPD26 program a graphic file (ex:.pcx,.ico,.bmp) to a Epson compatible printer ? (Of course,used Epson control caracter).

First of all, you need to read the pixels from the file. Here's some code that I use in our FPD 2.6 application to read PCX files with 256 colors and standard encoding (RLE). All colors belowe 128 are considered white, all above to be black:
	*-----------------------------------------------------------------
	* Wir lesen den Header der PCX-Datei ein, um zu überprüfen, ob 
	* diese das richtige Format hat. Wenn nicht, wird die PCX-Datei
	* wieder geschlossen und abgebrochen.
	*-----------------------------------------------------------------
	Private lcHeader
	lcHeader = Fread( m.lnFileHandle, 128 )
	If    Asc(Substr(m.lcHeader,4,1)) # 8 ;
	   or Asc(Substr(m.lcHeader,66,1)) # 1
		=Fclose( m.lnFileHandle )
		Return .F.
	Endif
	
	*-----------------------------------------------------------------
	* Die Höhe und Breite der Datei bestimmen.
	*-----------------------------------------------------------------
	Private lnWidth, lnHeight
	lnWidth = Asc(Substr(m.lcHeader,9,1)) + ;
		Asc(Substr(m.lcHeader,10,1))*256 + 1
	lnHeight = Asc(Substr(m.lcHeader,11,1)) + ;
		Asc(Substr(m.lcHeader,12,1))*256 + 1
	Dimension raObject[m.lnHeight]
	raObject = ""

	*-----------------------------------------------------------------
	* Das Bild einlesen. PCX verwendet ein Run Length Encoding Ver-
	* fahren, um Daten zu komprimieren. Das bedeutet, wenn ein Byte
	* in den Daten 0xC0 oder größer ist, gibt die Bits 0-5 die Anzahl
	* an, wieoft das nachfolgende Byte wiederholt werden soll. Dieser
	* Wert wird im nachfolgenden Code in der Variablen lnCount gespei-
	* chert. Ist dieser 0, wird der Wert direkt gelesen.
	*-----------------------------------------------------------------
	Private lnPixel, lnCount, lnByte, lnLine
	lnCount = 0
	lnLine = 1
	For lnPixel = 1 to m.lnWidth*m.lnHeight
		If m.lnCount == 0
			lnByte = Asc( Fread(m.lnFileHandle,1) )
			If m.lnByte >= 192
				lnCount = m.lnByte - 192
				lnByte = Asc( Fread(m.lnFileHandle,1) )
			Else
				lnCount = 1
			Endif
		Endif
		lnCount = m.lnCount - 1
		If m.lnByte > 127
			raObject[m.lnLine] = raObject[m.lnLine] + " "
		Else
			raObject[m.lnLine] = raObject[m.lnLine] + "#"
		Endif
		If Len(raObject[m.lnLine]) == m.lnWidth
			lnLine = m.lnLine + 1
		Endif
	Endfor
The image is in raObject afterwards. Once you got the image, you have to print it. Unlike images, dot matrix printers print severa lines at once. If I recall correctly, you have to submit the first pixel of 24 lines in the first 3 bytes, then the next pixel of the the same 24 lines in the following 3 bytes, etc. You can use BITSET() to create those bytes from the image.

Finally, you need send the image to the printer using the correct control codes which you've asked for in a different question, already.
--
Christof
Previous
Reply
Map
View

Click here to load this message in the networking platform