.PCX

 BBS: Inland Empire Archive
Date: 02-15-94 (13:23)             Number: 134
From: HARRY F. HARRISON            Refer#: 133
  To: JEFFREY ZAPATKA               Recvd: NO  
Subj: .PCX                           Conf: (2) Quik_Bas
 > Can Anyone help me with a routinie or file to give an example on how
 > I'd begin (or do it) to view a .PCX file in my QuickBASIC Program?

Orginally posted by Francois Roy on Mon 18 Oct 93 15:27

DECLARE SUB SetPalette (pcxpal$)
DECLARE SUB SelectScreen ()
DECLARE SUB ReadPCXLine (PCXFile%, TotalBytes%, ScanLine%())
DECLARE SUB ReadPCXByte (PCXFile%, value%)
DECLARE SUB OpenPCXFile (PCXName$, xsize%, ysize%, TotalBytes%, pcxpal$)
DEFINT A-Z
TYPE PCXHeaderStruc
    Manufacxturer AS STRING * 1
    Version AS STRING * 1
    Encoding AS STRING * 1
    BitsPerPixel AS STRING * 1
    xmin AS INTEGER
    ymin AS INTEGER
    xmax AS INTEGER
    ymax AS INTEGER
    Hres AS INTEGER
    Vres AS INTEGER
    ColorMap AS STRING * 48
    Reserved1 AS STRING * 1
    NumPlanes AS STRING * 1
    BytesPerLine AS INTEGER
    PaletteType AS INTEGER
    HScrSize AS INTEGER
    VScrSize AS INTEGER
    Resreved2 AS STRING * 54
END TYPE
DIM SHARED PCXheader AS PCXHeaderStruc
DIM SHARED PCXFile
DIM SHARED ScrMode, ScrMaxX, ScrMaxY
DIM SHARED ScrMaxColor, ScrBitsPerPixel
DIM SHARED Byte AS STRING * 1
DIM SHARED MaxScrMode

NoVGA: MaxScrMode = 9
 RESUME

SUB OpenPCXFile (PCXName$, xsize, ysize, TotalBytes, pcxpal$)
PCXFile = FREEFILE
OPEN PCXName$ FOR BINARY AS #PCXFile
GET #PCXFile, 1, PCXheader
pcxpal$ = LEFT$(PCXheader.ColorMap + STRING$(768, 0), 768)
IF ASC(PCXheader.Version) = 5 THEN
   SEEK #PCXFile, LOF(PCXFile) - 768&
   GET #PCXFile, , Byte
   IF ASC(Byte) = 12 THEN GET #PCXFile, , pcxpal$
END IF
xsize = PCXheader.xmax - PCXheader.xmin + 1
ysize = PCXheader.ymax - PCXheader.ymin + 1
TotalBytes = ASC(PCXheader.NumPlanes) * PCXheader.BytesPerLine
END SUB

SUB ReadPCXByte (PCXFile, value)
STATIC count, CountValue, BufferLOC, Buffer$

IF count > 0 THEN
   value = CountValue
   count = count - 1
ELSE
   IF BufferLOC > LEN(Buffer$) OR LEN(Buffer$) = 0 THEN
      BufferLEN& = LOF(PCXFile) - LOC(PCXFile)
      IF BufferLEN& > 15000 THEN
         BufferLEN& = 15000
      END IF
      IF BufferLEN& <= 0 OR EOF(PCXFile) THEN
         EXIT SUB
      END IF
      Buffer$ = SPACE$(BufferLEN&)
      GET #PCXFile, , Buffer$
      BufferLOC = 1
   END IF
   value = ASC(MID$(Buffer$, BufferLOC, 1))
   BufferLOC = BufferLOC + 1
   IF value >= 192 THEN
      count = value - 193
      IF BufferLOC >= LEN(Buffer$) THEN
         BufferLEN& = LOF(PCXFile) - LOC(PCXFile)
         IF BufferLEN& > 15000 THEN
            BufferLEN& = 15000
         END IF
         IF BufferLEN& <= 0 OR EOF(PCXFile) THEN
            EXIT SUB
         END IF
         Buffer$ = SPACE$(BufferLEN&)
         GET #PCXFile, , Buffer$
         BufferLOC = 1
      END IF
      CountValue = ASC(MID$(Buffer$, BufferLOC, 1))
      BufferLOC = BufferLOC + 1
      value = CountValue
   END IF
END IF

END SUB

---
 * Origin: Far Heap Corrupt - Abort, Retry, Ignore or Fail? (1:105/222.5)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET