static fpos_t spSeekStreamRPos(const ZStreamRPos& iStreamRPos, fpos_t iPos, int iWhence) { switch (iWhence) { case SEEK_SET: { iStreamRPos.SetPosition(iPos); return iStreamRPos.GetPosition(); } case SEEK_CUR: { size_t newPos = iStreamRPos.GetPosition() + iPos; iStreamRPos.SetPosition(newPos); return newPos; } case SEEK_END: { size_t newPos = iStreamRPos.GetSize() + iPos; iStreamRPos.SetPosition(newPos); return newPos; } } ZUnimplemented(); return -1; }
static ZRef<NPaintDataRep> sRead_NPaintDataRep(const ZStreamRPos& iStreamRPos, string& oFormat) { iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_BMP(iStreamRPos)) { oFormat = "bmp"; return theRep; } iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_GIF(iStreamRPos)) { oFormat = "gif"; return theRep; } iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_JPEG(iStreamRPos)) { oFormat = "jpg"; return theRep; } iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_PNG(iStreamRPos)) { oFormat = "png"; return theRep; } iStreamRPos.SetPosition(0); ZRef<NPaintDataRep> theRep = new NPaintDataRep; theRep->FromStream(iStreamRPos); if (theRep->HasData()) { oFormat = "kf"; return theRep; } return new NPaintDataRep(ZPoint(320, 240)); }