Updates to the quicktime plugin from Bob Kuehne.

This commit is contained in:
Robert Osfield
2003-03-03 11:02:35 +00:00
parent ec2e620f98
commit 5b7718ea45
4 changed files with 51 additions and 19 deletions

View File

@@ -65,10 +65,17 @@ Registry::Registry()
addFileExtensionAlias("inta", "rgb");
addFileExtensionAlias("bw", "rgb");
#if defined(__DARWIN_OSX__)
addFileExtensionAlias("jpg", "qt");
addFileExtensionAlias("jpe", "qt");
addFileExtensionAlias("jpeg", "qt");
addFileExtensionAlias("tif", "qt");
addFileExtensionAlias("tiff", "qt");
#else
addFileExtensionAlias("jpg", "jpeg");
addFileExtensionAlias("jpe", "jpeg");
addFileExtensionAlias("tif", "tiff");
#endif
// remove geo to lwo alias as the new Carbon Graphics GEO format
// also uses the .geo. It is still possible to load light wave .geo

View File

@@ -60,6 +60,8 @@ PORTIONS OF THIS CODE ARE COPYRIGHT APPLE COMPUTER -
#include <OpenGL/glu.h> // for OpenGL API
#include <OpenGL/glext.h> // for OpenGL extension support
#include "QTTexture.h"
// ==================================
enum // how to scale image to power of two on read if scaling
@@ -189,7 +191,7 @@ static unsigned char * LoadBufferFromImageFile ( FSSpec fsspecImage,
long *pBufferWidth, long *pBufferHeight, long *pBufferDepth)
{
unsigned char * pImageBuffer = NULL;
int scalefac, xoffs, yoffs;
int scalefac;
GWorldPtr pGWorld = NULL;
OSType pixelFormat;
long rowStride; // length, in bytes, of a pixel row in the image
@@ -255,7 +257,14 @@ static unsigned char * LoadBufferFromImageFile ( FSSpec fsspecImage,
}
SetRect (&rectImage, 0, 0, (short) *pBufferWidth, (short) *pBufferHeight); // l, t, r. b set image rectangle for creation of GWorld
rowStride = *pBufferWidth * *pBufferDepth >> 3; // set stride in bytes width of image * pixel depth in bytes
pImageBuffer = (unsigned char *) NewPtrClear (rowStride * *pBufferHeight); // build new buffer exact size of image (stride * height)
const long len = rowStride * *pBufferHeight;
pImageBuffer = new unsigned char [ len ]; // build new buffer exact size of image (stride * height)
// pImageBuffer = (unsigned char *) NewPtrClear (rowStride * *pBufferHeight); // build new buffer exact size of image (stride * height)
if (NULL == pImageBuffer)
{
sprintf ( errMess, "failed to allocate image buffer");
@@ -267,7 +276,8 @@ static unsigned char * LoadBufferFromImageFile ( FSSpec fsspecImage,
if (NULL == pGWorld)
{
sprintf ( errMess, "failed to create GWorld");
DisposePtr ((Ptr) pImageBuffer); // dump image buffer
// DisposePtr ((Ptr) pImageBuffer); // dump image buffer
delete [] pImageBuffer;
pImageBuffer = NULL;
CloseComponent(giComp);
return NULL; // if we failed to create gworld
@@ -295,7 +305,8 @@ static unsigned char * LoadBufferFromImageFile ( FSSpec fsspecImage,
DisposeGWorld (pGWorld); // dump gworld
pGWorld = NULL;
DisposePtr ((Ptr) pImageBuffer); // dump image buffer
// DisposePtr ((Ptr) pImageBuffer); // dump image buffer
delete [] pImageBuffer;
pImageBuffer = NULL;
CloseComponent(giComp); // dump component
return NULL;
@@ -340,14 +351,14 @@ FSSpec *darwinPathToFSSpec (char *fname ) {
unsigned char*
LoadBufferFromDarwinPath ( char *fname, long *origWidth, long *origHeight, long *origDepth,
LoadBufferFromDarwinPath ( const char *fname, long *origWidth, long *origHeight, long *origDepth,
long *buffWidth, long *buffHeight,
long *buffDepth)
{
FSSpec *fs;
sprintf ( errMess, "");
sprintf ( errMess, "" );
fs=darwinPathToFSSpec ( fname );
fs=darwinPathToFSSpec ( const_cast<char*>( fname ) );
if (fs == NULL) {
return NULL;

View File

@@ -0,0 +1,20 @@
#ifndef __QTTEXTURE_H__
#define __QTTEXTURE_H__
#ifdef __cplusplus
extern "C" {
#endif
unsigned char*
LoadBufferFromDarwinPath ( const char *fname, long *origWidth,
long *origHeight, long *origDepth,
long *buffWidth, long *buffHeight, long *buffDepth);
char *
QTfailureMessage(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -16,12 +16,7 @@
# define SEEK_SET 0
#endif
extern "C" unsigned char*
LoadBufferFromDarwinPath ( const char *fname, long *origWidth, long *origHeight, long *origDepth,
long *buffWidth, long *buffHeight, long *buffDepth);
extern "C" char *
QTfailureMessage(void);
#include "QTTexture.h"
using namespace osg;
@@ -149,17 +144,16 @@ class ReaderWriterQT : public osgDB::ReaderWriter
}
}
}
// DisposePtr ((Ptr) pixels);
Image* image = new Image();
image->setFileName(fileName.c_str());
image->setImage(buffWidth,buffHeight,1,
buffDepth >> 3,
pixelFormat,
GL_UNSIGNED_BYTE,
pixels );
pixels,
osg::Image::USE_NEW_DELETE );
notify(INFO) << "image read ok "<<buffWidth<<" "<<buffHeight<<std::endl;
return image;
}