/* This file is part of 8XI (TI-83 Plus) Format, a File Format plugin for Adobe Photoshop Copyright (C) 2006 Toby Thain, toby@telegraphics.com.au This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //#include #include #include #include "ti8xi.h" Handle indata; // some code reading this format can be found here: // http://www.activevb.de/rubriken/fileformats/ff_8xi/8xi.html // also in source code @ http://library.thinkquest.org/C0120001/HTMLobj-348/pictview.zip OSErr read_start(FormatRecordPtr pb,long *data){ OSErr e = noErr; char header[TI_HEADER_BYTES]; long count; count = sizeof(header); if(!FSREAD((FILEREF)pb->dataFork,&count,header) && !strncmp(header,TI8XI_SIG,4)){ // only check the "**TI" part pb->imageSize.h = TI8XI_COLS; pb->imageSize.v = TI8XI_ROWS; pb->rowBytes = TI8XI_COLS/8; count = (long)pb->rowBytes * pb->imageSize.v; /* this allocation must be done using Handle suite, since it was not allowed for in Prepare call (maxData). */ if( (indata = pb->handleProcs->newProc(count + 4)) ){ pb->imageMode = plugInModeBitmap; pb->depth = 1; pb->planes = 1; pb->imageHRes = pb->imageVRes = 72L<<16; pb->theRect.left = pb->theRect.top = 0; pb->theRect.right = pb->imageSize.h; pb->theRect.bottom = pb->imageSize.v; pb->loPlane = pb->hiPlane = 0; pb->colBytes = 1; pb->data = pb->handleProcs->lockProc(indata,false); // 1 -> black, 0 -> white e = FSREAD((FILEREF)pb->dataFork,&count,pb->data); }else e = memFullErr; }else e = formatCannotRead; return e; } OSErr read_continue(FormatRecordPtr pb,long *data){ pb->data = NULL; return noErr; } OSErr read_finish(FormatRecordPtr pb,long *data){ pb->handleProcs->disposeProc(indata); return noErr; }