/* This file is part of SGI Format, a File Format plugin for Adobe Photoshop Copyright (C) 2003-9 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 */ /* note that Photoshop has this odd behaviour: in 16 bit modes, it scales channel values to a range of 0..0x8000 before passing to plugin - we must allow for this */ unsigned fix16(unsigned x); void swapbytes(unsigned char *p,int n); /* if we compile with -opt speed, mrc should inline this */ unsigned fix16(unsigned x){ /* scale 0..0x8000 to 0..0xffff */ return ((long)x << 1) - (x >> 15); } void swapbytes(unsigned char *p,int n){ int i; unsigned char *q; /* swap bytes in words */ for(i = n, q = p; i--; q += 2){ unsigned t = q[0]; q[0] = q[1]; q[1] = t; } }