From: <bru...@us...> - 2009-02-01 17:59:36
|
Revision: 927 http://panotools.svn.sourceforge.net/panotools/?rev=927&view=rev Author: brunopostle Date: 2009-02-01 17:59:30 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Remove GPL incompatible files (bug #1861841), this removes mac classic support and hopefully doesn't break anything in OS X. Modified Paths: -------------- trunk/libpano/Makefile.am Removed Paths: ------------- trunk/libpano/PixMap.c trunk/libpano/PixMap.h trunk/libpano/README.mac trunk/libpano/makefile.mac trunk/libpano/pict.c Modified: trunk/libpano/Makefile.am =================================================================== --- trunk/libpano/Makefile.am 2009-02-01 17:37:06 UTC (rev 926) +++ trunk/libpano/Makefile.am 2009-02-01 17:59:30 UTC (rev 927) @@ -53,8 +53,8 @@ endif if HAVE_MAC -MAC_SRC = PixMap.c pict.c shell_mac.c sys_mac.c ppm.c -MAC_HDR = PixMap.h +MAC_SRC = shell_mac.c sys_mac.c ppm.c +MAC_HDR = install-exec-hook: @true @@ -102,11 +102,11 @@ rm -rf `find $(distdir) -name CVS` rm -rf `find $(distdir) -name .cvsignore` -EXTRA_DIST = gpl.txt README.linux README.windows README.mac \ - makefile.linux makefile.mac makefile.win32 \ +EXTRA_DIST = gpl.txt README.linux README.windows \ + makefile.linux makefile.win32 \ bootstrap filter.r libpano13.def pano13.rc \ - seamer_.c sys_X11.c sys_win.c bmp.c PixMap.c pict.c shell_mac.c \ - sys_mac.c ppm.c PixMap.h sys_ansi.c ppm.c ZComb.h adjust.h \ + seamer_.c sys_X11.c sys_win.c bmp.c shell_mac.c \ + sys_mac.c ppm.c sys_ansi.c ppm.c ZComb.h adjust.h \ pano13vc.def libpano.vcproj PanoTools.pbproj.tgz MAINTAINERCLEANFILES = \ Deleted: trunk/libpano/PixMap.c =================================================================== --- trunk/libpano/PixMap.c 2009-02-01 17:37:06 UTC (rev 926) +++ trunk/libpano/PixMap.c 2009-02-01 17:59:30 UTC (rev 927) @@ -1,1137 +0,0 @@ -/* File PixMap.c - PixMap manipulation routines, implementation. - Copyright (c) 1996, 1997 by John Montbriand. All Rights Reserved. - Permission hereby granted for public use. - Distribute freely in areas where the laws of copyright apply. - USE AT YOUR OWN RISK. - DO NOT DISTRIBUTE MODIFIED COPIES. - Comments/questions/postcards* to the author at the address: - John Montbriand - P.O. Box. 1133 - Saskatoon Saskatchewan Canada - S7K 3N2 - or by email at: - tin...@sk... - *if you mail a postcard, then I will provide you with technical support - regarding questions you may have about this file. - -*/ - - -#include "PixMap.h" -#include <Memory.h> -//#include <OSUtils.h> //commented by Kekus Digital -//#include <ToolUtils.h> //commented by Kekus Digital -//#include <FixMath.h> //commented by Kekus Digital -#include <Math.h> -//#include <Gestalt.h> //commented by Kekus Digital -//#include <ImageCompression.h> //commented by Kekus Digital -//#include <PictUtils.h> //commented by Kekus Digital -#include <QuickTime/ImageCompression.h> //added by Kekus Digital -#include <String.h> - - -PixMapHandle MakePixMap(short width, short height, CTabHandle clut) { - long row_bytes, depth; - Ptr raster_data; - long bytecount; - CTabHandle colours; - PixMapHandle newpix; - PixMapPtr pixptr; - - /* calculate required depth */ - if (clut == NULL) - depth = 8; - else if ((*clut)->ctSize < 2) - depth = 1; - else if ((*clut)->ctSize < 4) - depth = 2; - else if ((*clut)->ctSize < 16) - depth = 4; - else depth = 8; - - /* set up initial values for locals */ - row_bytes = ((depth * ((long) width) + 31) >> 5) << 2; - bytecount = row_bytes * ((long) height); - colours = NULL; - raster_data = NULL; - newpix = NULL; - - /* check for valid rowbytes */ - if (row_bytes > 0x00003FFF) goto bail; - - /* allocate the raster data */ - raster_data = NewPtrClear(bytecount); - if (raster_data == NULL) goto bail; - - /* copy the colour table */ - if (clut == NULL) { - colours = GetCTable(8); - if (colours == NULL) goto bail; - } else { - colours = clut; - if (HandToHand((Handle*) &colours) != noErr) { - colours = NULL; - goto bail; - } - } - /* create the pixmap handle */ - newpix = (PixMapHandle) NewHandleClear(sizeof(PixMap)); - if (newpix == NULL) goto bail; - - /* set up the pixmap fields */ - pixptr = *newpix; - pixptr->baseAddr = raster_data; - pixptr->rowBytes = (row_bytes | 0x8000); - pixptr->bounds.right = width; - pixptr->bounds.bottom = height; - pixptr->hRes = 0x00480000; /* resolution = 72 dots per inch */ - pixptr->vRes = 0x00480000; - pixptr->pixelSize = depth; - pixptr->cmpCount = 1; - pixptr->cmpSize = depth; - pixptr->pmTable = colours; - - /* done */ - return newpix; - -bail: - if (raster_data != NULL) DisposePtr(raster_data); - if (newpix != NULL) DisposeHandle((Handle) newpix); - if (colours != NULL) DisposeHandle((Handle) colours); - return NULL; -} - -PixMapHandle Make16BitPixMap(short width, short height) { - long row_bytes; - Ptr raster_data; - long bytecount, response; - CTabHandle colours; - PixMapHandle newpix; - PixMapPtr pixptr; - unsigned char *rowptr; - unsigned short *pixelptr; - short y, x; - - /* is it possible? */ - if (Gestalt(gestaltQuickdrawVersion, &response) != noErr) response = 0; - if (response < gestalt32BitQD) return NULL; - - /* set up initial values for locals */ - row_bytes = ((16 * ((long) width) + 31) >> 5) << 2; - bytecount = row_bytes * ((long) height); - colours = NULL; - raster_data = NULL; - newpix = NULL; - - /* check for valid rowbytes */ - if (row_bytes > 0x00003FFF) goto bail; - - /* allocate the raster data */ - raster_data = NewPtr(bytecount); - if (raster_data == NULL) goto bail; - rowptr = (unsigned char *) raster_data; - for (y=0; y< height; y++, rowptr += row_bytes) - for (pixelptr = (unsigned short *) rowptr, x=0; x<width; x++) - *pixelptr++ = 0x7FFF; - - /* dummy colour table */ - colours = (CTabHandle) NewHandleClear(8); - if (colours == NULL) goto bail; - (*colours)->ctSeed = 15; - (*colours)->ctSize = -1; - - /* create the pixmap handle */ - newpix = (PixMapHandle) NewHandleClear(sizeof(PixMap)); - if (newpix == NULL) goto bail; - - /* set up the pixmap fields */ - pixptr = *newpix; - pixptr->baseAddr = raster_data; - pixptr->rowBytes = (row_bytes | 0x8000); - pixptr->bounds.right = width; - pixptr->bounds.bottom = height; - pixptr->hRes = 0x00480000; /* resolution = 72 dots per inch */ - pixptr->vRes = 0x00480000; - pixptr->pixelSize = 16; - pixptr->pixelType = RGBDirect; - pixptr->cmpCount = 3; - pixptr->cmpSize = 5; - pixptr->pmTable = colours; - - /* done */ - return newpix; - -bail: - if (raster_data != NULL) DisposePtr(raster_data); - if (newpix != NULL) DisposeHandle((Handle) newpix); - if (colours != NULL) DisposeHandle((Handle) colours); - return NULL; -} - - -PixMapHandle Make32BitPixMap(short width, short height) { - long row_bytes; - Ptr raster_data; - long bytecount, response; - CTabHandle colours; - PixMapHandle newpix; - PixMapPtr pixptr; - unsigned char *rowptr; - unsigned long *pixelptr; - short y, x; - - /* is it possible? */ - if (Gestalt(gestaltQuickdrawVersion, &response) != noErr) response = 0; - if (response < gestalt32BitQD) return NULL; - - /* set up initial values for locals */ - row_bytes = ((32 * ((long) width) + 31) >> 5) << 2; - bytecount = row_bytes * ((long) height); - colours = NULL; - raster_data = NULL; - newpix = NULL; - - /* check for valid rowbytes */ - if (row_bytes > 0x00003FFF) goto bail; - - /* allocate the raster data */ - raster_data = NewPtr(bytecount); - if (raster_data == NULL) goto bail; - rowptr = (unsigned char *) raster_data; - for (y=0; y< height; y++, rowptr += row_bytes) - for (pixelptr = (unsigned long *) rowptr, x=0; x<width; x++) - *pixelptr++ = 0x00FFFFFF; - - /* dummy colour table */ - colours = (CTabHandle) NewHandleClear(8); - if (colours == NULL) goto bail; - (*colours)->ctSeed = 24; - (*colours)->ctSize = -1; - - /* create the pixmap handle */ - newpix = (PixMapHandle) NewHandleClear(sizeof(PixMap)); - if (newpix == NULL) goto bail; - - /* set up the pixmap fields */ - pixptr = *newpix; - pixptr->baseAddr = raster_data; - pixptr->rowBytes = (row_bytes | 0x8000); - pixptr->bounds.right = width; - pixptr->bounds.bottom = height; - pixptr->hRes = 0x00480000; /* resolution = 72 dots per inch */ - pixptr->vRes = 0x00480000; - pixptr->pixelSize = 32; - pixptr->pixelType = RGBDirect; - pixptr->cmpCount = 3; - pixptr->cmpSize = 8; - pixptr->pmTable = colours; - - /* done */ - return newpix; - -bail: - if (raster_data != NULL) DisposePtr(raster_data); - if (newpix != NULL) DisposeHandle((Handle) newpix); - if (colours != NULL) DisposeHandle((Handle) colours); - return NULL; -} - - -PixMapHandle MakeScreenLikePixMap(Rect *globalRect) { - long maxArea, area; - PixMapHandle device_pix; - GDHandle device; - short width, height; - Rect sect, device_box; - /* search for maximum intersecting device */ - device_pix = NULL; - maxArea = 0; - for (device = GetDeviceList(); device; device = GetNextDevice(device)) { - device_box = (*device)->gdRect; - if (TestDeviceAttribute(device, screenDevice) - && TestDeviceAttribute(device, screenActive) - && SectRect(globalRect, &device_box, §)) { - area = (sect.right - sect.left) * (sect.bottom - sect.top); - if (area > maxArea) { - device_pix = (*device)->gdPMap; - maxArea = area; - } - } - } - /* create a pixmap */ - if (device_pix != NULL) { - width = globalRect->right - globalRect->left; - height = globalRect->bottom - globalRect->top; - if ((*device_pix)->pixelSize <= 8) - return MakePixMap(width, height, (*device_pix)->pmTable); - else if ((*device_pix)->pixelSize == 16) - return Make16BitPixMap(width, height); - else if ((*device_pix)->pixelSize == 32) - return Make32BitPixMap(width, height); - } - return NULL; -} - - -void KillPixMap(PixMapHandle pix) { - DisposePtr((*pix)->baseAddr); - DisposeHandle((Handle) (*pix)->pmTable); - DisposeHandle((Handle) pix); -} - -long PixMapSize(PixMapHandle pix) { - if (pix == NULL) return 0; - return GetPtrSize((*pix)->baseAddr) - + GetHandleSize((Handle) (*pix)->pmTable) - + GetHandleSize((Handle) pix); -} - -void SetPixMapPixel(PixMapHandle pix, short h, short v, long value) { - long row_bytes; - unsigned char *dst; - row_bytes = (*pix)->rowBytes & 0x00003FFF; - dst = (unsigned char *) (*pix)->baseAddr; - switch ((*pix)->pixelSize) { - case 1: - dst += ((long) v) * row_bytes; - if (value != 0) BitSet(dst, h); else BitClr(dst, h); - break; - case 2: - dst += ((long) v) * row_bytes + ((long) (h>>2)); - switch (h&3) { - case 0: - *dst = ((*dst) & 0x3F) | (value<<6); - break; - case 1: - *dst = ((*dst) & 0xCF) | ((value&0x03)<<4); - break; - case 2: - *dst = ((*dst) & 0xF3) | ((value&0x03)<<2); - break; - case 3: - *dst = ((*dst) & 0xFC) | (value&0x03); - break; - } - break; - case 4: - dst += ((long) v) * row_bytes + ((long) (h>>1)); - if ((h&1) == 0) { - *dst = ((*dst) & 0x0F) | (value<<4); - } else { - *dst = ((*dst) & 0xF0) | (value & 0x0F); - } - break; - case 8: - dst += ((long) v) * row_bytes + ((long) h); - *dst = (unsigned char) value; - break; - case 16: - dst += ((long) v) * row_bytes + (((long) h) * 2); - * ((short*) dst) = (short) value; - break; - case 32: - dst += ((long) v) * row_bytes + (((long) h) * 4); - * ((long*) dst) = value; - break; - } -} - - -long GetPixMapPixel(PixMapHandle pix, short h, short v) { - long row_bytes, the_value; - unsigned char *src; - row_bytes = ((*pix)->rowBytes & 0x00003FFF); - src = (unsigned char *) (*pix)->baseAddr; - switch ((*pix)->pixelSize) { - case 1: - src += ((long) v) * row_bytes; - if (BitTst(src, h)) the_value = 1; else the_value = 0; - break; - case 2: - src += ((long) v) * row_bytes + (((long) h) >> 2); - switch (h&3) { - case 0: - the_value = (long) (((*src) >> 6) & 0x03); - break; - case 1: - the_value = (long) (((*src) >> 4) & 0x03); - break; - case 2: - the_value = (long) (((*src) >> 2) & 0x03); - break; - case 3: - the_value = (long) ((*src) & 0x03); - break; - } - break; - case 4: - src += ((long) v) * row_bytes + (((long) h) >> 1); - if ((h&1) == 0) { - the_value = (long) (((*src) >> 4) & 0x0F); - } else { - the_value = (long) ((*src) & 0x0F); - } - break; - case 8: - src += ((long) v) * row_bytes + ((long) h); - the_value = (long) ((*src) & 0x000000FF); - break; - case 16: - src += ((long) v) * row_bytes + (((long) h) << 1); - the_value = (long) ((* ((short*) src)) & 0x0000FFFF); - break; - case 32: - src += ((long) v) * row_bytes + (((long) h) << 2); - the_value = * ((long*) src); - break; - } - return the_value; -} - - -#if defined(powerc) || defined(__powerc) - -static short pixround(float x) { - float low, high; - low = floor(x); - high = ceil(x); - if (fabs(low - x) < fabs(high - x)) - return (short) low; - else return (short) high; -} - -PixMapHandle RotatePixMap(PixMapHandle pix, short cx, short cy, float angle) { - unsigned long srcrow, dstrow; - long x, y, width, height; - unsigned char *srcbase, *dstbase, *d; - float rad, crad, srad, zx, zy; - short hpos, vpos; - PixMapHandle new_pix; - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.right, (*pix)->bounds.bottom, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else return NULL; - if (new_pix != NULL) { - rad = 0.017453 * angle; - crad = cos(rad); - srad = sin(rad); - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - switch ((*pix)->pixelSize) { - case 1: - case 2: - case 4: - for (y = 0; y < height; y++) - for (x = 0; x < width; x++) { - zx = (float) (x - cx); - zy = (float) (y - cy); - vpos = pixround((zy*crad) - (zx*srad) + ((float) cy)); - if (vpos >= 0 && vpos < height) { - hpos = pixround((zx*crad) + (zy*srad) + ((float) cx)); - if (hpos >= 0 && hpos < width) - SetPixMapPixel(new_pix, x, y, GetPixMapPixel(pix, hpos, vpos)); - } - } - break; - case 8: - for (y = 0; y < height; y++, dstbase += dstrow) - for (d = dstbase, x = 0; x < width; x++, d++) { - zx = (float) (x - cx); - zy = (float) (y - cy); - vpos = pixround((zy*crad) - (zx*srad) + ((float) cy)); - if (vpos >= 0 && vpos < height) { - hpos = pixround((zx*crad) + (zy*srad) + ((float) cx)); - if (hpos >= 0 && hpos < width) - *d = *(srcbase + vpos * srcrow + hpos); - } - } - break; - case 16: - for (y = 0; y < height; y++, dstbase += dstrow) - for (d = dstbase, x = 0; x < width; x++, d += 2) { - zx = (float) (x - cx); - zy = (float) (y - cy); - vpos = pixround((zy * crad) - (zx * srad) + ((float) cy)); - if (vpos >= 0 && vpos < height) { - hpos = pixround((zx * crad) + (zy * srad) + ((float) cx)); - if (hpos >= 0 && hpos < width) - * ((short*) d) = * ((short*) (srcbase + vpos * srcrow + (hpos<<1))); - } - } - break; - case 32: - for (y = 0; y < height; y++, dstbase += dstrow) - for (d = dstbase, x = 0; x < width; x++, d += 4) { - zx = (float) (x - cx); - zy = (float) (y - cy); - vpos = pixround((zy * crad) - (zx * srad) + ((float) cy)); - if (vpos >= 0 && vpos < height) { - hpos = pixround((zx * crad) + (zy * srad) + ((float) cx)); - if (hpos >= 0 && hpos < width) - * ((long*) d) = * ((long*) (srcbase + vpos * srcrow + (hpos<<2))); - } - } - break; - } - } - return new_pix; -} - -#else - -PixMapHandle RotatePixMap(PixMapHandle pix, short cx, short cy, float angle) { - unsigned long srcrow, dstrow; - long x, y, i, width, height; - unsigned char *srcbase, *dstbase, *d, *s; - Fixed rad, crad, srad, zx, zy, cxx, cyy; - short hpos, vpos; - PixMapHandle new_pix; - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.right, (*pix)->bounds.bottom, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else return NULL; - if (new_pix != NULL) { - rad = FixMul(0x00000478, X2Fix(angle)); - crad = FracCos(rad); - srad = FracSin(rad); - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - cxx = FixRatio(cx, 1); - cyy = FixRatio(cy, 1); - switch ((*pix)->pixelSize) { - case 1: - case 2: - case 4: - for (y = 0; y < height; y++) - for (x = 0; x < width; x++) { - zx = FixRatio(x, 1) - cxx; - zy = FixRatio(y, 1) - cyy; - vpos = FixRound(FracMul(zy, crad) - FracMul(zx, srad) + cyy); - if (vpos >= 0 && vpos < height) { - hpos = FixRound(FracMul(zx, crad) + FracMul(zy, srad) + cxx); - if (hpos >= 0 && hpos < width) - SetPixMapPixel(new_pix, x, y, GetPixMapPixel(pix, hpos, vpos)); - } - } - break; - case 8: - for (y = 0; y < height; y++, dstbase += dstrow) - for (d = dstbase, x = 0; x < width; x++, d++) { - zx = FixRatio(x, 1) - cxx; - zy = FixRatio(y, 1) - cyy; - vpos = FixRound(FracMul(zy, crad) - FracMul(zx, srad) + cyy); - if (vpos >= 0 && vpos < height) { - hpos = FixRound(FracMul(zx, crad) + FracMul(zy, srad) + cxx); - if (hpos >= 0 && hpos < width) - *d = *(srcbase + vpos * srcrow + hpos); - } - } - break; - case 16: - for (y = 0; y < height; y++, dstbase += dstrow) - for (d = dstbase, x = 0; x < width; x++, d += 2) { - zx = FixRatio(x, 1) - cxx; - zy = FixRatio(y, 1) - cyy; - vpos = FixRound(FracMul(zy, crad) - FracMul(zx, srad) + cyy); - if (vpos >= 0 && vpos < height) { - hpos = FixRound(FracMul(zx, crad) + FracMul(zy, srad) + cxx); - if (hpos >= 0 && hpos < width) - * ((short*) d) = * ((short*) (srcbase + vpos * srcrow + (hpos<<1))); - } - } - break; - case 32: - for (y = 0; y < height; y++, dstbase += dstrow) - for (d = dstbase, x = 0; x < width; x++, d += 4) { - zx = FixRatio(x, 1) - cxx; - zy = FixRatio(y, 1) - cyy; - vpos = FixRound(FracMul(zy, crad) - FracMul(zx, srad) + cyy); - if (vpos >= 0 && vpos < height) { - hpos = FixRound(FracMul(zx, crad) + FracMul(zy, srad) + cxx); - if (hpos >= 0 && hpos < width) - * ((long*) d) = * ((long*) (srcbase + vpos * srcrow + (hpos<<2))); - } - } - break; - } - } - return new_pix; -} - -#endif - - -PixMapHandle RotatePixRight(PixMapHandle pix) { - unsigned long srcrow, dstrow, x, y, dstcol, width, height; - unsigned char *srcbase, *dstbase, *s, *d; - PixMapHandle new_pix; - - /* establish the next pixmap */ - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.bottom, (*pix)->bounds.right, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.bottom, (*pix)->bounds.right); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.bottom, (*pix)->bounds.right); - else return NULL; - - if (new_pix == NULL) return NULL; - - /* set up locals */ - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - dstcol = height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - - /* rotate the image */ - switch ((*pix)->pixelSize) { - case 1: - case 2: - case 4: - for (y = 0; y < height; y++) - for (x=0; x < width; x++) - SetPixMapPixel(new_pix, height - y - 1, x, GetPixMapPixel(pix, x, y)); - break; - case 8: - for (y = 0; y < height; y++, srcbase += srcrow) - for (s = srcbase, d = dstbase + (--dstcol), x=0; x < width; x++, d += dstrow) - *d = *s++; - break; - case 16: - for (y = 0; y < height; y++, srcbase += srcrow) - for (s = srcbase, d = dstbase + ((--dstcol) << 1), x=0; x < width; x++, s += 2, d += dstrow) - * ((short*) d) = * ((short*) s); - break; - case 32: - for (y = 0; y < height; y++, srcbase += srcrow) - for (s = srcbase, d = dstbase + ((--dstcol) << 2), x=0; x < width; x++, s += 4, d += dstrow) - * ((long*) d) = * ((long*) s); - break; - } - - /* done */ - return new_pix; -} - - -PixMapHandle RotatePixLeft(PixMapHandle pix) { - unsigned long srcrow, dstrow, x, y, dstcol, width, height; - unsigned char *srcbase, *dstbase, *s, *d, *dststart; - PixMapHandle new_pix; - - /* get the next pixmap */ - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.bottom, (*pix)->bounds.right, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.bottom, (*pix)->bounds.right); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.bottom, (*pix)->bounds.right); - else return NULL; - if (new_pix == NULL) return NULL; - - /* set up the locals */ - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - dststart = dstbase + ((width-1) * dstrow); - dstcol = 0; - - /* rotate the image */ - switch ((*pix)->pixelSize) { - case 1: - case 2: - case 4: - for (y = 0; y < height; y++) - for (x=0; x < width; x++) - SetPixMapPixel(new_pix, y, width - x - 1, GetPixMapPixel(pix, x, y)); - break; - case 8: - for (y = 0; y < height; y++, srcbase += srcrow) - for (s = srcbase, d = dststart + (dstcol++), x = 0; x < width; x++, d -= dstrow) - *d = *s++; - break; - case 16: - for (y = 0; y < height; y++, srcbase += srcrow) - for (s = srcbase, d = dststart + ((dstcol++) << 1), x = 0; x < width; x++, s += 2, d -= dstrow) - * ((short*) d) = * ((short*) s); - break; - case 32: - for (y = 0; y < height; y++, srcbase += srcrow) - for (s = srcbase, d = dststart + ((dstcol++) << 2), x = 0; x < width; x++, s += 4, d -= dstrow) - * ((long*) d) = * ((long*) s); - break; - } - return new_pix; -} - -PixMapHandle FlipPixVertical(PixMapHandle pix) { - unsigned long srcrow, dstrow, y, width, height; - unsigned char *srcbase, *dstbase; - PixMapHandle new_pix; - - /* get the next pixmap */ - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.right, (*pix)->bounds.bottom, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else return NULL; - if (new_pix == NULL) return NULL; - - /* set up the locals */ - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - dstbase += (height * dstrow); - - /* flip the image */ - for (y=0; y < height; y++) { - dstbase -= dstrow; - BlockMoveData(srcbase, dstbase, dstrow); - srcbase += srcrow; - } - return new_pix; -} - -PixMapHandle FlipPixHorizontal(PixMapHandle pix) { - unsigned long srcrow, dstrow, x, y, width, height; - unsigned char *srcbase, *dstbase, *s, *d; - PixMapHandle new_pix; - - /* get the next pixmap */ - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.right, (*pix)->bounds.bottom, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else return NULL; - if (new_pix == NULL) return NULL; - - /* set up the locals */ - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - - /* flip the image */ - switch ((*pix)->pixelSize) { - case 1: - case 2: - case 4: - for (y = 0; y < height; y++) - for (x=0; x < width; x++) - SetPixMapPixel(new_pix, width - x - 1, y, GetPixMapPixel(pix, x, y)); - break; - case 8: - for (y = 0; y < height; y++, srcbase += srcrow, dstbase += dstrow) - for(s = srcbase + width, d = dstbase, x = 0; x < width; x++) - *d++ = *--s; - break; - case 16: - for (y = 0; y < height; y++, srcbase += srcrow, dstbase += dstrow) - for(s = srcbase + (width << 1) - 2, d = dstbase, x = 0; x < width; x++, d += 2, s -= 2) - * ((short*) d) = * ((short*) s); - break; - case 32: - for (y = 0; y < height; y++, srcbase += srcrow, dstbase += dstrow) - for(s = srcbase + (width << 2) - 4, d = dstbase, x = 0; x < width; x++, d += 4, s -= 4) - * ((long*) d) = * ((long*) s); - break; - } - return new_pix; -} - - -PixMapHandle DuplicatePixMap(PixMapHandle pix) { - unsigned long srcrow, dstrow, y, width, height; - unsigned char *srcbase, *dstbase; - PixMapHandle new_pix; - - /* get the next pixmap */ - if ((*pix)->pixelSize <= 8) - new_pix = MakePixMap((*pix)->bounds.right, (*pix)->bounds.bottom, (*pix)->pmTable); - else if ((*pix)->pixelSize == 16) - new_pix = Make16BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else if ((*pix)->pixelSize == 32) - new_pix = Make32BitPixMap((*pix)->bounds.right, (*pix)->bounds.bottom); - else return NULL; - if (new_pix == NULL) return NULL; - - /* set up the locals */ - srcrow = ((*pix)->rowBytes & 0x3FFF); - dstrow = ((*new_pix)->rowBytes & 0x3FFF); - srcbase = (unsigned char*) (*pix)->baseAddr; - dstbase = (unsigned char*) (*new_pix)->baseAddr; - height = (*pix)->bounds.bottom; - width = (*pix)->bounds.right; - - /* copy the image */ - for (y=0; y < height; y++) { - BlockMoveData(srcbase, dstbase, dstrow); - srcbase += srcrow; - dstbase += dstrow; - } - return new_pix; -} - - -PixMapHandle PICTToPixMap(PicHandle pic, CTabHandle clut) { - Rect bounds; - PixMapHandle pix; - PixMapPort *pxmp; - bounds = (*pic)->picFrame; - OffsetRect(&bounds, -bounds.left, -bounds.top); - pix = MakePixMap(bounds.right, bounds.bottom, clut); - if (pix != NULL) - WithPixMap(pix, pxmp) { - DrawPicture(pic, &bounds); - } - return pix; -} - -PixMapHandle PICTTo16BitPixMap(PicHandle pic) { - Rect bounds; - PixMapHandle pix; - PixMapPort *pxmp; - bounds = (*pic)->picFrame; - OffsetRect(&bounds, -bounds.left, -bounds.top); - pix = Make16BitPixMap(bounds.right, bounds.bottom); - if (pix != NULL) - WithPixMap(pix, pxmp) { - DrawPicture(pic, &bounds); - } - return pix; -} - - -PixMapHandle PICTTo32BitPixMap(PicHandle pic) { - Rect bounds; - PixMapHandle pix; - PixMapPort *pxmp; - bounds = (*pic)->picFrame; - OffsetRect(&bounds, -bounds.left, -bounds.top); - pix = Make32BitPixMap(bounds.right, bounds.bottom); - if (pix != NULL) - WithPixMap(pix, pxmp) { - DrawPicture(pic, &bounds); - } - return pix; -} - - -PicHandle PixMapToPICT(PixMapHandle pix) { - PicHandle pic; - GrafPtr saved; - //CGrafPort port;//commented by Kekus Digital - CGrafPtr port;//added by Kekus Digital - Rect bounds; - bounds = (*pix)->bounds; - GetPort(&saved); - //OpenCPort(&port);//commented by Kekus Digital - port = CreateNewPort();//added by Kekus Digital - pic = OpenPicture(&bounds); - ClipRect(&bounds); - PlotPixMap(pix, 0, 0, srcCopy); - ClosePicture(); - SetPort(saved); - //ClosePort((GrafPtr) &port);//commented by Kekus Digital - DisposePort(port);//added by Kekus Digital - if (GetHandleSize((Handle) pic) == sizeof(Picture)) { - KillPicture(pic); - pic = NULL; - } - return pic; -} - - -PicHandle PixMapToCompressedPICT(PixMapHandle pix) { - GrafPtr saved; - //CGrafPort port;//commented by Kekus Digital - CGrafPtr port;//added by Kekus Digital - PicHandle pic; - Rect bounds; - OSErr err; - long buffersize, response; - Ptr compBuffer; - ImageDescriptionHandle iDesc; - Boolean port_open; - - /* can it be done? */ - if (Gestalt(gestaltCompressionMgr, &response) != noErr) return NULL; - - /* initial state */ - compBuffer = NULL; - iDesc = NULL; - pic = NULL; - port_open = false; - - /* draw the picture, make sure we have a port */ - GetPort(&saved); - //OpenCPort(&port);//commented by Kekus Digital - port = CreateNewPort();//added by Kekus Digital - ClipRect(&bounds); - port_open = true; - - /* calculate sizes */ - bounds = (*pix)->bounds; - err = GetMaxCompressionSize(pix, &bounds, 0, codecHighQuality, 'jpeg', anyCodec, &buffersize); - if (err != noErr) goto bail; - - /* allocate storage */ - compBuffer = NewPtr(buffersize); - if ((err = MemError()) != noErr) goto bail; - iDesc = (ImageDescriptionHandle) NewHandleClear(sizeof(ImageDescription)); - if ((err = MemError()) != noErr) goto bail; - - /* compress the image */ - err = CompressImage(pix, &bounds, codecHighQuality, 'jpeg', iDesc, compBuffer); - if (err != noErr) goto bail; - - /* put the compressed image in a picture */ - pic = OpenPicture(&bounds); - ClipRect(&bounds); - err = DecompressImage(compBuffer, iDesc, pix, &bounds, &bounds, srcCopy, NULL); - ClosePicture(); - - /* verify that the picture is ok */ - if (err != noErr || GetHandleSize((Handle) pic) == sizeof(Picture)) goto bail; - - /* clean up and go */ - SetPort(saved); - //ClosePort((GrafPtr) &port);//commented by Kekus Digital - DisposePort(port);//added by Kekus Digital - DisposePtr(compBuffer); - DisposeHandle((Handle) iDesc); - return pic; - -bail: - if (port_open) { - SetPort(saved); - //ClosePort((GrafPtr) &port);//commented by Kekus Digital - DisposePort(port);//added by Kekus Digital - } - if (pic != NULL) KillPicture(pic); - if (compBuffer != NULL) DisposePtr(compBuffer); - if (iDesc != NULL) DisposeHandle((Handle) iDesc); - return NULL; -} - - -PixMapPort* NewPxMP(PixMapHandle pix) { - GDHandle the_device; - ITabHandle inverse_table; - PixMapPort* pxmp; - Boolean device_active; - Rect r; - RgnHandle the_VisRgn = nil; - - /* set up initial variable states */ - the_device = NULL; - inverse_table = NULL; - pxmp = NULL; - device_active = false; - - /* allocate the pxmp */ - pxmp = (PixMapPort*) NewPtr(sizeof(PixMapPort)); - if (pxmp == NULL) goto bail; - - /* create the graphics device */ - inverse_table = (ITabHandle) NewHandleClear(2); - if (inverse_table == NULL) goto bail; - if ((*pix)->pixelSize <= 8) { /* set it up only for indexed devices */ - MakeITable((*pix)->pmTable, inverse_table, 4); - if (QDError() != noErr) goto bail; - } - - /* create the graphics device */ - the_device = (GDHandle) NewHandleClear(sizeof(GDevice)); - if (the_device == NULL) goto bail; - if ((*pix)->pixelSize <= 8) - (*the_device)->gdType = clutType; - else (*the_device)->gdType = directType; - (*the_device)->gdITable = inverse_table; - (*the_device)->gdResPref = 4; - (*the_device)->gdPMap = pix; - (*the_device)->gdRect = (*pix)->bounds; - (*the_device)->gdMode = -1; - SetDeviceAttribute(the_device, gdDevType, true); - SetDeviceAttribute(the_device, noDriver, true); - - /* save the current grafport and device */ - GetPort(&pxmp->saved_port); - pxmp->saved_device = GetGDevice(); - - /* set the current device to the new one*/ - SetGDevice((pxmp->pdevice = the_device)); - device_active = true; - - /* Open the new grafport*/ - //OpenCPort(&pxmp->pport);//commented by Kekus Digital - pxmp->pport = CreateNewPort();//added by Kekus Digital - //SetPort((GrafPtr) &pxmp->pport); //commented by Kekus Digital - SetPort((GrafPtr) pxmp->pport); //added by Kekus Digital - r = (*pix)->bounds; - PortSize(r.right, r.bottom); - ClipRect(&r); - //RectRgn(pxmp->pport.visRgn, &r);//commented by Kekus Digital - - GetPortVisibleRegion(pxmp->pport,the_VisRgn );//added by Kekus Digital - RectRgn(the_VisRgn, &r);//added by Kekus Digital - - /* done */ - return pxmp; - -bail: - if (device_active) SetGDevice(pxmp->saved_device); - if (inverse_table != NULL) DisposeHandle((Handle) inverse_table); - if (the_device != NULL) DisposeHandle((Handle) the_device); - if (pxmp != NULL) DisposePtr((Ptr) pxmp); - return NULL; -} - -void DisposePxMP(PixMapPort* px) { - if (px->pdevice == GetGDevice()) { - SetGDevice(px->saved_device); - SetPort(px->saved_port); - } - //CloseCPort(&px->pport);//commented by Kekus Digital - DisposePort(px->pport);//added by Kekus Digital - DisposeHandle((Handle) ((*px->pdevice)->gdITable)); - DisposeHandle((Handle) (px->pdevice)); - DisposePtr((Ptr) px); -} - -void PlotPixMap(PixMapHandle pix, short h, short v, short mode) { - GrafPtr port; - Rect src, dst; - char hstate; - GetPort(&port); - hstate = HGetState((Handle) pix); - HLock((Handle) pix); - src = dst = (*pix)->bounds; - OffsetRect(&dst, h, v); - //CopyBits((BitMap *) (*pix), &port->portBits, &src, &dst, mode, NULL);//commented by Kekus Digital - CopyBits((BitMap *) (*pix), GetPortBitMapForCopyBits(port), &src, &dst, mode, NULL);//added by Kekus Digital - HSetState((Handle) pix, hstate); -} - -void PixMapCopy(PixMapHandle pix, Rect *src, Rect *dst, short mode) { - GrafPtr port; - char hstate; - GetPort(&port); - hstate = HGetState((Handle) pix); - HLock((Handle) pix); - //CopyBits((BitMap *) (*pix), &port->portBits, src, dst, mode, NULL);//commented by Kekus Digital - CopyBits((BitMap *) (*pix), GetPortBitMapForCopyBits(port), src, dst, mode, NULL);//added by Kekus Digital - HSetState((Handle) pix, hstate); -} - -PixPatHandle PixMap2PixPat(PixMapHandle pix, Pattern *the_pattern) { - PixPat ppat; - PixMap pmap; - PixPatHandle the_pixpat; - long bytecount; - char ctstate; - short width, height; - OSErr err; - - /* recoverable state */ - the_pixpat = NULL; - - /* check parameters */ - if ((*pix)->pixelSize > 8) goto bail; - width = (*pix)->bounds.right; - if (width != 8 && width != 16 && width != 32 && width != 64 && width != 128) - goto bail; - height = (*pix)->bounds.bottom; - if (height != 8 && height != 16 && height != 32 && height != 64 && height != 128) - goto bail; - - /* set variables to correct initial settings */ - bytecount = ((long) ((*pix)->rowBytes & 0x3FFF)) * ((long) (*pix)->bounds.bottom); - ppat.patType = 1; - ppat.patMap = (PixMapHandle) sizeof(PixPat); - ppat.patData = (Handle) (sizeof(PixPat) + sizeof(PixMap)); - ppat.patXData = NULL; - ppat.patXValid = -1; - ppat.patXMap = NULL; - ppat.pat1Data = *the_pattern; - pmap = **pix; - pmap.baseAddr = NULL; - pmap.pmTable = (CTabHandle) (sizeof(PixPat) + sizeof(PixMap) + bytecount); - - /* add the PixPat header */ - err = PtrToHand(&ppat, (Handle*) &the_pixpat, sizeof(ppat)); - if (err != noErr) goto bail; - - /* ... then the PixMap */ - err = PtrAndHand(&pmap, (Handle) the_pixpat, sizeof(PixMap)); - if (err != noErr) goto bail; - - /* ... then the raster data */ - err = PtrAndHand((*pix)->baseAddr, (Handle) the_pixpat, bytecount); - if (err != noErr) goto bail; - - /* ... and finally the colour table */ - ctstate = HGetState((Handle) (*pix)->pmTable); - HLock((Handle) (*pix)->pmTable); - err = PtrAndHand(*((*pix)->pmTable), (Handle) the_pixpat, GetHandleSize((Handle) (*pix)->pmTable)); - HSetState((Handle) (*pix)->pmTable, ctstate); - if (err != noErr) goto bail; - - /* done */ - return the_pixpat; - -bail: - if (the_pixpat != NULL) DisposeHandle((Handle) the_pixpat); - return NULL; -} - - -CTabHandle CalcPixMapColours(PixMapHandle pix) { - CTabHandle clut; - OSErr err; - clut = NULL; - if ((*pix)->pixelSize <= 8) { - clut = (*pix)->pmTable; - if (HandToHand((Handle *) &clut) != noErr) clut = NULL; - } else { - PictInfo pictinfo; - memset(&pictinfo, 0, sizeof(pictinfo)); - err = GetPixMapInfo(pix, &pictinfo, - returnColorTable+suppressBlackAndWhite, - 254, medianMethod, 0); - if (err == noErr) clut = pictinfo.theColorTable; - } - return clut; -} - - - Deleted: trunk/libpano/PixMap.h =================================================================== --- trunk/libpano/PixMap.h 2009-02-01 17:37:06 UTC (rev 926) +++ trunk/libpano/PixMap.h 2009-02-01 17:59:30 UTC (rev 927) @@ -1,245 +0,0 @@ -/* File PixMap.h Copyright (C) 1997 by John R. Montbriand. All Rights Reserved. */ - -#ifndef __PIXMAP__ -#define __PIXMAP__ - -/* File PixMap.h - PixMap manipulation routines, definitions. - Copyright (c) 1996, 1997 by John Montbriand. All Rights Reserved. - Permission hereby granted for public use. - Distribute freely in areas where the laws of copyright apply. - USE AT YOUR OWN RISK. - DO NOT DISTRIBUTE MODIFIED COPIES. - Comments/questions/postcards* to the author at the address: - John Montbriand - P.O. Box. 1133 - Saskatoon Saskatchewan Canada - S7K 3N2 - or by email at: - tin...@sk... - *if you mail a postcard, then I will provide you with technical support - regarding questions you may have about this file. - -*/ - -//#include <Types.h> // commented by Kekus Digital -//#include <QuickDraw.h> // commented by Kekus Digital -#include <Carbon/Carbon.h> // added by Kekus Digital - -#ifdef __cplusplus -extern "C" { -#endif - - -/* version number for this interface (version 1) */ - -#define kPixMapVersion 1 - - -/* MakePixMap creates a new pixmap handle with the requested - dimensions. If there is not enough memory to allocate the pixmap, - MakePixMap will return NULL. if clut is NULL, then the default - 256 colour table (clut = 8) is used. if clut is not NULL, then a - copy of it is used in the pixmap. The number of colours in the clut - determines the pixel depth of the created pixmap as follows: - 2 colours -> 1 pit per pixel, - 3 to 4 colours -> 2 bits per pixel, - 5 to 16 colours -> 4 bits per pixel, - 17 to 256 colours -> 8 bits per pixel. */ - -PixMapHandle MakePixMap(short width, short height, CTabHandle clut); - - -/* Make16BitPixMap creates a new pixmap handle with the requested - dimensions. If there is not enough memory to allocate the pixmap, - Make16BitPixMap will return NULL. The created pixmap utilizes 16 bit - colour and allocates 16 bits per each pixel. Make32BitPixMap is - identical however it allocates 32 bits per pixel. */ - -PixMapHandle Make16BitPixMap(short width, short height); -PixMapHandle Make32BitPixMap(short width, short height); - - -/* MakeScreenLikePixMap creates a pixmap mirroring the attributes of the - pixmap used to draw largest area of *globalRect on the screen */ -PixMapHandle MakeScreenLikePixMap(Rect *globalRect); - - -/* KillPixMap disposes of a pixmap allocated by one of the - routines herein. */ -void KillPixMap(PixMapHandle pix); - - -/* PixMapSize returns the number of bytes occupied by the pixmap. */ -long PixMapSize(PixMapHandle pix); - - -/* SetPixMapPixel and GetPixMapPixel are for getting or setting - individual pixel values. */ - -void SetPixMapPixel(PixMapHandle pix, short h, short v, long value); -long GetPixMapPixel(PixMapHandle pix, short h, short v); - - -/* RotatePixRight creates a new pixmap containing the image - stored in the parameter pixmap rotated 90 degrees to the right. - The resulting pixmap is appropriately sized: i.e. if the source - pixmap is 100 pixels wide and 200 pixels tall, then the result - pixmap pointer will be 200 pixels wide and 100 pixels tall. */ - -PixMapHandle RotatePixRight(PixMapHandle pix); - - -/* RotatePixLeft creates a new pixmap containing the image stored in - the parameter bitmap pointer rotated 90 degrees to the left. The - resulting pixmap is appropriately sized: i.e. if the source pixmap - is 100 pixels wide and 200 pixels tall, then the result pixmap - pointer will be 200 pixels wide and 100 pixels tall. */ - -PixMapHandle RotatePixLeft(PixMapHandle pix); - - -/* FlipPixVertical creates a new pixmap containing the image stored - in the parameter pixmap flipped upside down. The resulting - pixmap will be the same size as the original image. */ - -PixMapHandle FlipPixVertical(PixMapHandle pix); - - -/* FlipPixHorizontal creates a new pixmap containing the image stored - in the parameter pixmap flipped horizontally. The resulting pixmap - will be the same size as the original image. */ - -PixMapHandle FlipPixHorizontal(PixMapHandle pix); - - -/* RotatePixMap creates a new pixmap containing the image from - the parameter pixmap rotated angle degrees about the center (cx, cy). - The resultant pixmap will have the same dimensions as the parameter - pixmap regardless of the angle specified. */ - -PixMapHandle RotatePixMap(PixMapHandle pix, short cx, short cy, float angle); - - -/* DuplicatePixMap creates a copy of the pixmap parameter. */ - -PixMapHandle DuplicatePixMap(PixMapHandle pix); - - -/* PICTToBitMap creates a new pixmap the using the size information - provided in the QuickDraw picture pointer parameter and draws - the picture in the pixmap before returning the pixmap. */ - -PixMapHandle PICTToPixMap(PicHandle pic, CTabHandle clut); -PixMapHandle PICTTo16BitPixMap(PicHandle pic); -PixMapHandle PICTTo32BitPixMap(PicHandle pic); - - -/* PixMapToPICT returns a QuickDraw picture that will draw the - image stored in the pixmap. PixMapToPICT is the inverse - of PICTToPixMap. */ - -PicHandle PixMapToPICT(PixMapHandle pix); - - -/* PixMapToCompressedPICT returns a QuickDraw picture that will draw the - image stored in the pixmap. PixMapToCompressedPICT is the inverse - of PICTToPixMap. */ - -PicHandle PixMapToCompressedPICT(PixMapHandle pix); - - - -/* ROUTINES FOR DRAWING TO... */ - -/* PixMapPort data structure managed by the routines NewBMP and - DisposeBMP. You should never have to access the fields of this - record directly as it's all taken care of by NewBMP and DisposeBMP. */ - -typedef struct { - //CGrafPort pport; /* the grafport record for drawing into the pixmap */ // commented by Kekus Digital - CGrafPtr pport; /* the grafport record for drawing into the pixmap */ // added by Kekus Digital - GDHandle pdevice; /* gdevice for drawing into the pixmap */ - GDHandle saved_device; /* saved gdevice */ - GrafPtr saved_port; /* saved grafport for later restoration */ - PixMapHandle pix; /* the pixmap */ -} PixMapPort; - - -/* NewBMP is called by the WithBitMap macro and you should never have to - call it directly yourself. What it does is it locks the pixmap, saves the - original grafport, and creates a new grafport suitable for drawing into - the pixmap. NewBMP should be followed by a call to DisposeBMP which - will restore the original grafport, unlock the pixmap, and dispose of the - new grafport. */ - -PixMapPort* NewPxMP(PixMapHandle pix); - - - -/* DisposePxMP unlocks the pixmap pointer passed to NewPxMP, deallocates - the grafport allocated for it, and restores the original grafport. - the macro WithBitMap calls this routine automatically and you will - not normally have to call it directly. */ - -void DisposePxMP(PixMapPort* px); - - - -/* WithPixMap is a macro facility that sets up the drawing environment - such that any drawing commands in the statement following the - macro instantiation will draw into the pixmap handle provided as - the first parameter. The parameters are declared as follows: - PixMapHandle pix; - PixMapPort* pxmp; */ - -#define WithPixMap(pix, pxmp) \ - for (pxmp = NewPxMP(pix); \ - pxmp != NULL; \ - DisposePxMP(pxmp), pxmp = NULL) - - - - -/* ROUTINES FOR DRAWING FROM... */ - -/* PlotPixMap provides a simple interface for drawing a pixmap in - the current grafport. The pixmap is drawn with the top left corner - aligned with the point (h,v) using the indicated transfer mode. */ - -void PlotPixMap(PixMapHandle pix, short h, short v, short mode); - - -/* PixMapCopy copies bits from the pixmap to the current port - from the src rectangle to the destination using the indicated - copy mode. */ - -void PixMapCopy(PixMapHandle pix, Rect *src, Rect *dst, short mode); - - -/* PixMap2PixPat converts a pixmap to a pixel pattern resource. The - pixmap's dimensions should be some power of two - (i.e. 8, 16, 32, 64, or 128). */ - -PixPatHandle PixMap2PixPat(PixMapHandle pix, Pattern *the_pattern); - - -/* CalcPixMapColours calculates a colour table for the colours - used in the pixmap. For indexed images, CalcPixMapColours returns - a copy of the pixmap's colour table, otherwise, for direct - images, it calls GetPixMapInfo. */ - -CTabHandle CalcPixMapColours(PixMapHandle pix); - - -#ifdef __cplusplus -}; -#endif - -#endif - -/* end of File PixMap.h */ - - - - Deleted: trunk/libpano/README.mac =================================================================== --- trunk/libpano/README.mac 2009-02-01 17:37:06 UTC (rev 926) +++ trunk/libpano/README.mac 2009-02-01 17:59:30 UTC (rev 927) @@ -1,81 +0,0 @@ -Readme Sources - -This file describes how to build the library pano13.lib -for the Macintosh operating system. This library is required -for running the Panorama Tools plug-in and any of the -Panorama Tools applications (PTStitcher, etc). - -Legal Issues: - -This software is distributed under GNU-license, see the -file COPYING for details. Some parts of the software -are derived from other sources, which are distributed under -different copyrights. These are: -(1) The JPEG-library distributed by the Independent JPEG group. -This package contains a precompiled binary of the JPEG -library and the header files required for compilation -in the folder Sources/libs/. The legal terms for using the -JPEG library can be found in the file /copyright/README_JPEG. -(2) The PNG-library written by G.E.Schalnat et al. -This package contains a precompiled binary of the PNG -library and the header files required for compilation -in the folder Sources/libs/. The legal terms for using the -PNG library can be found in the file Sources/libs/png.h -(3) The TIFF-library by Sam Leffler/ Silicon Graphics Inc. -This package contains a precompiled binary of the TIFF -library and the header files required for compilation -in the folder Sources/libs/. The legal terms for using the -TIFF library can be found in the file /copyright/README_TIFF. -(4) The ZLIB-library by Jean-loup Gailly and Mark Adler. -This package contains a precompiled binary of the ZLIB -library and the header files required for compilation -in the folder Sources/libs/. The legal terms for using the -ZLIB library can be found in the file zlib.h. -(5) The public domain Levenberg-Marquardt solver -of the Argonne National Laboratories MINPACK mathematical library, -C translation by Steve Moshier (file lmdif.c). -(6) Fast fourier transformation, code by: -RC Singleton, Stanford Research Institute, Sept. 1968 -Copyright MJ Olesen, Queen's University at Kingston, 1995-97. -See the file fftn.c for details. -(7) PixMap-manipulation routines by John Montbriand. See -the file PixMap.h for the copyright notice. - - -Requirements: - -A working MPW installation (Macintosh Programmers Workshop) -is required to build the library. MPW is free and can be -downloaded from www.apple.com. - -The Java Development MRJ is required. It is also free -and can be downloaded from www.apple.com. -During the build of pano13.lib the java include -files have to be accessed by the MRC-compiler. - - -Building the Library: - -The source files of this distribution have to be unpacked. -Open the Makefile (folder 'src') using MPW, and edit path settings -for your system (eg the path to your MRJ-installation). -In the directory 'src' issue the command 'Build pano13.lib'. -There will be a couple of warning -messages which are non-fatal and can be ignored. - -Limits and Modifications: - -This distribution of the sources limits processing -of fisheye images to fields of view smaller than -160 degrees. This limit is controlled by the constant -MAX_FISHEYE_FOV in the file filter.h. There -is some controversy regarding the legality of processing -hemispherical images (ie images having 180 degree field -of view) in connection with virtual reality panoramas. -If your application of fisheye lenses is not prohibited -by patents, you can build and use your own unlimited version -of the library by changing the source code. - -Helmut Dersch -d...@fh... - Deleted: trunk/libpano/makefile.mac =================================================================== --- trunk/libpano/makefile.mac 2009-02-01 17:37:06 UTC (rev 926) +++ trunk/libpano/makefile.mac 2009-02-01 17:59:30 UTC (rev 927) @@ -1,100 +0,0 @@ -# Panorama_Tools - Generate, Edit and Convert Panoramic Images -# Copyright (C) 1998,1999 - Helmut Dersch de...@fh... -# -# 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ -# -# - -############################################################################# - -# All functional code and resources are located in pano13.lib -# The code in the filters only translates the 68k-code-resource call -# from GraphicConverter into a call to the ppc-entry function -# "filter_main" with an appropriate selector value. - -############################################################################# - -# -------------- Definitions ------------------------- - -Lib_Exports = pano13.x - -PPCInc = panorama.h filter.h fftn.h f2c.h PixMap.h pteditor.h \xB6 - ptutils.h sys_mac.h version.h - -PPCSrc = filter.c parser.c queryfeature.c sys_mac.c correct.c perspect.c \xB6 - adjust.c remap.c lmdif.c file.c \xB6 - math.c pan.c PTDialogs.c fftn.c fourier.c resample.c \xB6 - shell_mac.c optimize.c morpher.c Triangulate.c png.c \xB6 - seamer.c ptpicker.c pteditor.c seamer_.c \xB6 - tiff.c pict.c jpeg.c PixMap.c - -OtherSrc = filter.r Gimpmain.c bmp.c pano13.x libpano13.def ppm.c resource.h \xB6 - sys_X11.c sys_X11.h sys_win.c sys_win.h sys_ansi.h sys_ansi.c \xB6 - - - -PPCObjs = filter.x.o parser.x.o queryfeature.x.o sys_mac.x.o correct.x.o perspect.x.o \xB6 - adjust.x.o remap.x.o lmdif.x.o file.x.o \xB6 - math.x.o pan.x.o PTDialogs.x.o fftn.x.o fourier.x.o resample.x.o \xB6 - shell_mac.x.o optimize.x.o morpher.x.o Triangulate.x.o png.x.o \xB6 - seamer.x.o ptpicker.x.o pteditor.x.o tiff.x.o pict.x.o jpeg.x.o PixMap.x.o - -FORMAT_LIBS = ::jpeg-6:libjpeg.a \xB6 - ::tiff-v3.4:libtiff:libtiff.o \xB6 - ::libpng-0.89c:libpng.a \xB6 - "{SharedLibraries}"QuickTimeLib - - - -PPC_Libraries = "{SharedLibraries}"InterfaceLib \xB6 - "{SharedLibraries}"StdCLib \xB6 - "{PPCLibraries}"StdCRuntime.o \xB6 - "{PPCLibraries}"PPCCRuntime.o \xB6 - "{SharedLibraries}"MathLib \xB6 - "{SharedLibraries}"ColorSyncLib \xB6 - "{PPCLibraries}"MrCPlusLib.o \xB6 - "{SharedLibraries}"JNILib \xB6 - {FORMAT_LIBS} - - -############################################################################## - -# -------------- Build Rules ------------------------- - -.x.o \xC4 .c - MrC -d Macintosh -align mac68k -i ::jpeg-6 -i ::tiff-v3.4:libtiff -i ::libpng-0.89c -i :: -i ::libpng-0.89c:zlib-1.0.4 {default}.c -o {default}.x.o - -# MrC -d Macintosh {default}.c -o {default}.x.o - - -# This shared library contains all functional code and resources - -pano13.lib \xC4\xC4 {PPCObjs} filter.r Makefile {Lib_Exports} {PPC_Libraries} - PPCLink -xm s -init __my_initialize -term __my_terminate \xB6 - -export `ConvertExportList {Lib_Exports}` \xB6 - {PPCObjs} {PPC_Libraries} -o {targ} # Create library - MergeFragment -n pano13.lib -c -t pwpc -x {targ} # use MergeFragment to create a library cfrg - Rez -d SystemSevenOrLater=1 -a filter.r -o {Targ} # Stuff all resources into library - setfile -c '????' -t 'shlb' {Targ} - - -Backup \xC4 - Duplicate -y Makefile {PPCInc} {PPCSrc} {OtherSrc} :Backup: - - -clean \xC4 - Delete {PPCObjs} pano13.lib - - Deleted: trunk/libpano/pict.c =================================================================== --- trunk/libpano/pict.c 2009-02-01 17:37:06 UTC (rev 926) +++ trunk/libpano/pict.c 2009-02-01 17:59:30 UTC (rev 927) @@ -1,490 +0,0 @@ -/*#include <Gestalt.h> //commented by Kekus Digital -#include "filter.h" - -#include <FixMath.h> -#include <ImageCompression.h> -#include <Movies.h> -#include <QuickTimeComponents.h> -#include <StandardFile.h> -#include <PictUtils.h> -#include <Memory.h> -#include <OSUtils.h> -#include <ToolUtils.h> -#include <Math.h> -#include <Gestalt.h> -#include <ImageCompression.h>*/ // till here -#include "PixMap.h" -#include <carbon/carbon.h> //added by Kekus Digital -#include <QuickTime/QuickTimeComponents.h> -#include <QuickTime/ImageCompression.h> // till here - -#include <String.h> -#include "filter.h" -#include <stdio.h> - -#include "jpeglib.h" - - -static void FSpWritePicture (const FSSpec *spec, PicHandle pictData); -static PicHandle FSpReadPicture (const FSSpec *spec) ; -static PicHandle ImageToPICT (Image *im) ; -static int PICTtoImage ( Image *im, PicHandle pic ); -static int qtimporter( Image *im, fullPath *sfile ); - -int writePICT ( Image *im, fullPath *sfile ); -int readPICT ( Image *im, fullPath *sfile ); -int readJPEG( Image *im, fullPath *sfile ); -int readTIFF( Image *im, fullPath *sfile ); - - - -int writePICT( Image *im, fullPath *sfile ) -{ - PicHandle pic = NULL; - - TwoToOneByte( im ); // Pict doesn't support 16bit channels - - pic = ImageToPICT( im ); - if( pic == NULL ) - { - PrintError("Could not create Picture"); - return -1; - } - FSpWritePicture ( sfile, pic); - KillPicture(pic); - - return 0; -} - -int readPICT ( Image *im, fullPath *sfile ) -{ - PicHandle pic = NULL; - int result = 0; - - pic = FSpReadPicture (sfile); - if( pic == NULL ) - { - PrintError("Could not read Picture"); - return -1; - } - - if( PICTtoImage ( im, pic ) != 0) - { - PrintError("Could not convert Picture"); - result = -1; - } - - KillPicture(pic); - return result; -} - - - -static void FSpWritePicture (const FSSpec *spec, PicHandle pictData) -{ - short fRefNum; - long zeroData = 0L, zeroDataLen, pictLength; - int i; - -// FSpCreate(spec, 'GKON', 'PICT', smSystemScript); - FSpOpenDF(spec, fsWrPerm, &fRefNum); - - zeroDataLen = sizeof(long); - for (i = 0; i < 512 / zeroDataLen; i++) - FSWrite(fRefNum, &zeroDataLen, &zeroData); - - pictLength = GetHandleSize((Handle)pictData); - HLock((Handle)pictData); - FSWrite(fRefNum, &pictLength, *pictData); - HUnlock((Handle)pictData); - - FSClose(fRefNum); -} - - - -static PicHandle FSpReadPicture (const FSSpec *spec) -{ - PicHandle pictData; - short fRefNum; - long fileSize, pictLength; - - FSpOpenDF(spec, fsRdPerm, &fRefNum); - GetEOF(fRefNum, &fileSize); - SetFPos(fRefNum, fsFromStart, 512); - - pictLength = fileSize - 512; - pictData = (PicHandle)NewHandle(pictLength); - if( pictData != nil ) - { - HLock((Handle)pictData); - FSRead(fRefNum, &pictLength, *pictData); - HUnlock((Handle)pictData); - } - FSClose(fRefNum); - - return(pictData); -} - -static PicHandle ImageToPICT(Image *im) -{ - GrafPtr saved; - //CGrafPort port;//commented by Kekus Digital - CGrafPtr port;//added by Kekus Digital - Rect bounds; - PixMapHandle pix = NULL; - PicHandle pic = NULL; - - long row_bytes; - Ptr raster_data; - long bytecount, response; - CTabHandle colours; - PixMapPtr pixptr; - unsigned char *rowptr; - unsigned long *pixelptr; - short y, x; - - /* is it possible? */ - if (Gestalt(gestaltQuickdrawVersion, &response) != noErr) response = 0; - if (response < gestalt32BitQD) return NULL; - - /* set up initial values for locals */ - row_bytes = ((32 * ((long) im->width) + 31) >> 5) << 2; - if( row_bytes != im->bytesPerLine ) - { - PrintError("Alignment problem: Rowbytes != bytesPerLine"); - return NULL; - } - bytecount = row_bytes * ((long) im->height); - colours = NULL; - raster_data = NULL; - - /* check for valid rowbytes */ - if (row_bytes > 0x00003FFF) goto bail; - - /* allocate the raster data */ - raster_data = (Ptr)*(im->data); - rowptr = (unsigned char *) raster_data; - for (y=0; y< im->height; y++, rowptr += row_bytes) - for (pixelptr = (unsigned long *) rowptr, x=0; x<im->width; x++) - *pixelptr++ &= 0x00FFFFFF; - - /* dummy colour table */ - colours = (CTabHandle) NewHandleClear(8); - if (colours == NULL) goto bail; - (*colours)->ctSeed = 24; - (*colours)->ctSize = -1; - - /* create the pixmap handle */ - pix = (PixMapHandle) NewHandleClear(sizeof(PixMap)); - if (pix == NULL) goto bail; - - /* set up the pixmap fields */ - HLock((Handle) pix); - pixptr = *pix; - pixptr->baseAddr = raster_data; - pixptr->rowBytes = (row_bytes | 0x8000); - pixptr->bounds.right = im->width; - pixptr->bounds.bottom = im->height; - pixptr->hRes = 0x00480000; /* resolution = 72 dots per inch */ - pixptr->vRes = 0x00480000; - pixptr->pixelSize = 32; - pixptr->pixelType = RGBDirect; - pixptr->cmpCount = 3; - pixptr->cmpSize = 8; - pixptr->pmTable = colours; - - bounds = (*pix)->bounds; - GetPort(&saved); - //OpenCPort(&port);//commented by Kekus Digital - port = CreateNewPort();//added by Kekus Digital - pic = OpenPicture(&bounds); - ClipRect(&bounds); - PlotPixMap(pix, 0, 0, srcCopy); - ClosePicture(); - SetPort(saved); - //ClosePort((GrafPtr) &port);//commented by Kekus Digital - DisposePort(port);//added by Kekus Digital - if (GetHandleSize((Handle) pic) == sizeof(Picture)) { - KillPicture(pic); - pic = NULL; - } -bail: - if (pix != NULL) DisposeHandle((Handle) pix); - if (colours != NULL) DisposeHandle((Handle) colours); - return pic; -} - - -static int PICTtoImage( Image *im, PicHandle pic ) -{ - Rect bounds; - PixMapHandle pix = NULL; - PixMapPort *pxmp; - PictInfo pInfo; - - long row_bytes; - Ptr raster_data; - Handle hdl_raster_data = NULL; - long bytecount, response; - CTabHandle colours; - PixMapPtr pixptr; - unsigned char *rowptr; - unsigned long *pixelptr; - short y, x; - - - if( GetPictInfo( pic, &pInfo, recordComments, (short) 0,systemMethod,(short) 0 ) != noErr ) - { - PrintError("Could not get Pict-info"); - return -1; - } - - bounds = pInfo.sourceRect; //(*pic)->picFrame; - OffsetRect(&bounds, -bounds.left, -bounds.top); - - /* is it possible? */ - if (Gestalt(gestaltQuickdrawVersion, &response) != noErr) response = 0; - if (response < gestalt32BitQD) return -1; - - /* set up initial values for locals */ - row_bytes = ((32 * ((long) bounds.right) + 31) >> 5) << 2; - bytecount = row_bytes * ((long) bounds.bottom); - colours = NULL; - raster_data = NULL; - - /* check for valid rowbytes */ - if (row_bytes > 0x00003FFF) return -1; - - /* allocate the raster data */ - hdl_raster_data=NewHandle(bytecount); - if (hdl_raster_data == NULL) - { - PrintError("Not enough memory to load picture"); - return -1; - } - HLock(hdl_raster_data); - - raster_data = *hdl_raster_data; - rowptr = (unsigned char *) raster_data; - for (y=0; y< bounds.bottom; y++, rowptr += row_bytes) - for (pixelptr = (unsigned long *) rowptr, x=0; x<bounds.right; x++) - *pixelptr++ = 0x00FFFFFF; - - /* dummy colour table */ - colours = (CTabHandle) NewHandleClear(8); - if( colours == NULL) return -1; - - (*colours)->ctSeed = 24; - (*colours)->ctSize = -1; - - /* create the pixmap handle */ - pix = (PixMapHandle) NewHandleClear(sizeof(PixMap)); - if (pix == NULL) return -1; - - /* set up the pixmap fields */ - HLock((Handle)pix); - pixptr = *pix; - pixptr->baseAddr = raster_data; - pixptr->rowBytes = (row_bytes | 0x8000); - pixptr->bounds.right = bounds.right; - pixptr->bounds.bottom = bounds.bottom; - pixptr->hRes = pI... [truncated message content] |