Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ucbcad!ucbvax!sdcsvax!ucsdhub!hp-sdd!hplabs!hpcea!hpcid!tedj From: tedj@hpcid.HP.COM (Ted Johnson) Newsgroups: comp.sys.mac Subject: Help wanted: LSC, MacPaint Message-ID: <3320023@hpcid.HP.COM> Date: Mon, 28-Sep-87 17:38:27 EDT Article-I.D.: hpcid.3320023 Posted: Mon Sep 28 17:38:27 1987 Date-Received: Wed, 30-Sep-87 06:42:21 EDT Lines: 115 The following 90 line program is my attempt at using a SFGetFile dialog to select a MacPaint file, and then using CopyBits to display the file on the Mac's screen. This program is meant to be a Lightspeed C version of Technical Note #86, which gave a Pascal example for reading a MacPaint file. Unfortunately, this program displays junk (it looks like "snow" on a TV screen) on the Mac's screen instead of the MacPaint picture. Any clues as to where I'm going wrong would be greatly appreciated! (I suspect that my syntax in calling CopyBits() is wrong...) -Ted P.S. I am using LSC 2.01, upgraded to 2.11, on a SE HD20 running System/Finder 4.1/5.5. ****************************************************************** Ted C. Johnson Hewlett-Packard, Design Technology Center Santa Clara, CA (408)553-3555 UUCP: hplabs!hpcea!hpcid!tedj ****************************************************************** /*---------------------------cut here-------------------------------*/ /*For the sake of brevity, I have omitted all the manager "#include"s, the comments, and the error message handling.*/ #define YES 1 #define NIL 0L #define DefaultVolume 0 #define MaxFileSize 51840 SFReply theReply; Point SFGetwhere = { 90, 82 }; Ptr srcPtr, dstPtr, saveDstPtr; int srcFile, scanLine, errCode, vRef, refNum; long srcSize; GrafPort aPort; BitMap theBitMap; Rect screen; char buffer[1000]; Str255 fn; main() { InitGraf(&thePort); if (OldFile(&fn, &vRef) != YES) ExitToShell(); srcPtr = NewPtr(MaxFileSize); if (srcPtr == NIL) ExitToShell(); errCode = FSOpen(&fn, vRef, &refNum); if (errCode != noErr) ExitToShell(); srcSize = 512; errCode = FSRead(refNum, &srcSize, srcPtr); if (errCode != noErr) ExitToShell(); errCode = GetEOF(refNum, &srcSize); if (errCode != noErr) ExitToShell(); srcSize = srcSize - 512; errCode = FSRead(refNum, &srcSize, srcPtr); if (errCode != noErr) ExitToShell(); errCode = FSClose(refNum); if (errCode != noErr) ExitToShell(); dstPtr = NewPtr(MaxFileSize); if (dstPtr == NIL) ExitToShell(); saveDstPtr = dstPtr; for (scanLine = 1; scanLine <= 720; scanLine++) { UnpackBits(srcPtr, dstPtr, 72); } OpenPort(&aPort); SetRect(&screen, 0, 0, 576, 720); theBitMap.baseAddr = saveDstPtr; theBitMap.rowBytes = 72; theBitMap.bounds = screen; CopyBits(&theBitMap, &(aPort.portBits), &(aPort.portRect), &(aPort.portRect), srcCopy, NIL); do { ; } while (!Button()); } OldFile(fn, vRef) Str255 *fn; int *vRef; { SFTypeList fileTypes; int success_flag; fileTypes[0] = 'PNTG'; SFGetFile(SFGetwhere, "\pPick a paint file", 0L, 1, fileTypes, 0L, &theReply); if (theReply.good == YES) { pStrCopy(theReply.fName, fn); *vRef = theReply.vRefNum; success_flag = YES; } else { success_flag = NO; } return(success_flag); }