/Source/System/Image/WS/OSGImage.cpp
C++ | 4396 lines | 3567 code | 562 blank | 267 comment | 508 complexity | ff0725ce8aebf3f44e101061dc457d17 MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- /*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2000-2002 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
- \*---------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library 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 *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
- \*---------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
- \*---------------------------------------------------------------------------*/
- #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
- #pragma GCC diagnostic warning "-Wsign-compare"
- #endif
- #ifdef WIN32
- #pragma warning( disable : 4018 )
- #endif
- //---------------------------------------------------------------------------
- // Includes
- //---------------------------------------------------------------------------
- #define OSG_COMPILEIMAGE
- #include <cstdlib>
- #include <cstdio>
- #include <algorithm>
- #include "OSGConfig.h"
- #include "OSGLog.h"
- #include "OSGImageGenericAtt.h"
- #include "OSGFieldContainerFields.h"
- #include "OSGFileSystem.h"
- #include "OSGImageFileHandler.h"
- #include "OSGSquish.h"
- /*
- #include "OSGPathHandler.h"
- #include "OSGSceneFileHandler.h"
- */
- #include "OSGImage.h"
- OSG_USING_NAMESPACE
- /*! \class OSG::Image
- 1D/2D/3D Image with various pixel types data, can also optional hold
- mipMap and simple multi-frame data.
- */
- /*------------------------------------------------------------------------*/
- /* static member */
- /*! Static dictionary to map pixelData values to the bytes per pixel
- (bpp) value.
- Internaly used in the createData() method.
- */
- UInt32 Image::_formatDic[][2] =
- {
- { OSG_A_PF, 1 },
- { OSG_I_PF, 1 },
- { OSG_L_PF, 1 },
- { OSG_LA_PF, 2 },
- { OSG_RGB_PF, 3 },
- { OSG_RGBA_PF, 4 },
- { OSG_BGR_PF, 3 },
- { OSG_BGRA_PF, 4 },
- { OSG_RGB_DXT1, 3 },
- { OSG_RGBA_DXT1, 4 },
- { OSG_RGBA_DXT3, 4 },
- { OSG_RGBA_DXT5, 4 },
- { OSG_ALPHA_INTEGER_PF, 1 },
- { OSG_RGB_INTEGER_PF, 3 },
- { OSG_RGBA_INTEGER_PF, 4 },
- { OSG_BGR_INTEGER_PF, 3 },
- { OSG_BGRA_INTEGER_PF, 4 },
- { OSG_LUMINANCE_INTEGER_PF, 1 },
- { OSG_LUMINANCE_ALPHA_INTEGER_PF, 2 }
- };
- Int32 Image::_typeDic[][2] =
- {
- { OSG_INVALID_IMAGEDATATYPE, 0 },
- { OSG_UINT8_IMAGEDATA, 1 },
- { OSG_UINT16_IMAGEDATA, 2 },
- { OSG_UINT32_IMAGEDATA, 4 },
- { OSG_FLOAT32_IMAGEDATA, 4 },
- { OSG_FLOAT16_IMAGEDATA, 2 },
- { OSG_INT16_IMAGEDATA, 2 },
- { OSG_INT32_IMAGEDATA, 4 }
- };
- /*----------------------------- class specific ----------------------------*/
- void Image::initMethod(InitPhase ePhase)
- {
- }
- /*! Inform parents, when image was changed
- */
- void Image::changed(ConstFieldMaskArg whichField,
- UInt32 origin,
- BitVector details)
- {
- const Image *pThis = this;
- MFParentFieldContainerPtr::const_iterator parentsIt =
- pThis->_mfParents.begin();
- MFParentFieldContainerPtr::const_iterator parentsEnd =
- pThis->_mfParents.end();
- while(parentsIt != parentsEnd)
- {
- (*parentsIt)->changed(
- TypeTraits<BitVector>::One << parentsIt.getParentFieldPos(),
- ChangedOrigin::Child,
- whichField);
- ++parentsIt;
- }
- if(0x0000 != (whichField & DataTypeFieldMask))
- {
- // Update internals
- Int32 mapSizeType = sizeof(_typeDic) / sizeof(UInt32[2]);
- UInt32 typeFormat = 0;
- Int32 i;
-
- for(i = 0; i < mapSizeType; i++)
- {
- if(_typeDic[i][0] == _sfDataType.getValue())
- {
- typeFormat = _typeDic[i][1];
- }
- }
-
- setComponentSize( typeFormat );
- }
- if(0x0000 != (whichField & (MipMapCountFieldMask |
- WidthFieldMask |
- HeightFieldMask |
- DepthFieldMask |
- PixelFormatFieldMask )))
- {
- setSideSize(calcMipmapSumSize(_sfMipMapCount.getValue()));
- }
- if(0x0000 != (whichField & (SideSizeFieldMask | SideCountFieldMask)))
- {
- setFrameSize(_sfSideSize.getValue() * _sfSideCount.getValue());
- }
- calcMipmapOffsets();
- Inherited::changed(whichField, origin, details);
- }
- /*----------------------------- output ------------------------------------*/
- void Image::dump( UInt32 ,
- const BitVector ) const
- {
- const Char8 *pfStr = "UNDEF_PIXEL_FORMAT";
- const Char8 *typeStr = "INVALID_IMAGEDATA_TYPE";
- switch(getPixelFormat())
- {
- case OSG_A_PF:
- pfStr = "ALPHA";
- break;
- case OSG_I_PF:
- pfStr = "INTENSITY";
- break;
- case OSG_L_PF:
- pfStr = "LUMINANCE";
- break;
- case OSG_LA_PF:
- pfStr = "LUMINANCE_ALPHA";
- break;
- case OSG_BGR_PF:
- pfStr = "BGR";
- break;
- case OSG_BGRA_PF:
- pfStr = "BGRA";
- break;
- case OSG_RGB_PF:
- pfStr = "RGB";
- break;
- case OSG_RGBA_PF:
- pfStr = "RGBA";
- break;
- case OSG_RGB_DXT1:
- pfStr = "RGB_DXT1";
- break;
- case OSG_RGBA_DXT1:
- pfStr = "RGBA_DXT1";
- break;
- case OSG_RGBA_DXT3:
- pfStr = "RGBA_DXT3";
- break;
- case OSG_RGBA_DXT5:
- pfStr = "RGBA_DXT5";
- break;
- case OSG_ALPHA_INTEGER_PF:
- pfStr = "ALPHA_INTEGER";
- break;
- case OSG_RGB_INTEGER_PF:
- pfStr = "RGB_INTEGER";
- break;
- case OSG_RGBA_INTEGER_PF:
- pfStr = "RGBA_INTEGER";
- break;
- case OSG_BGR_INTEGER_PF:
- pfStr = "BGR_INTEGER";
- break;
- case OSG_BGRA_INTEGER_PF:
- pfStr = "BGRA_INTEGER";
- break;
- case OSG_LUMINANCE_INTEGER_PF:
- pfStr = "LUMINANCE_INTEGER";
- break;
- case OSG_LUMINANCE_ALPHA_INTEGER_PF:
- pfStr = "LUMINANCE_ALPHA_INTEGER";
- break;
- default:
- pfStr = "UNKNOWN_PIXEL_FORMAT";
- break;
- };
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE UCHAR8";
- break;
- case OSG_UINT16_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE UCHAR16";
- break;
- case OSG_UINT32_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE UCHAR32";
- break;
- case OSG_FLOAT16_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE FLOAT16";
- break;
- case OSG_FLOAT32_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE FLOAT32";
- break;
- case OSG_INT16_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE INT16";
- break;
- case OSG_INT32_IMAGEDATA:
- typeStr = "IMAGEDATA_TYPE INT32";
- break;
- default:
- typeStr = "UNKNOWN_IMAGEDATA_TYPE";
- break;
- };
- FLOG (("ImageDump: %s; %d/%d/%d; #mm: %d, side %d, #frame: %d, "
- "frameDelay %g, dataType %s, size: %ld\n",
- pfStr,
- getWidth(),
- getHeight(),
- getDepth(),
- getMipMapCount(),
- getSideCount(),
- getFrameCount(),
- getFrameDelay(),
- typeStr,
- getSize()));
- }
- // Return the number of components per pixel.
- UInt8 Image::getComponents(void) const
- {
- UInt16 mapSizeFormat = sizeof(_formatDic) / sizeof(UInt32[2]);
- for(UInt16 i = 0; i < mapSizeFormat; i++)
- {
- if(_formatDic[i][0] == getPixelFormat())
- return _formatDic[i][1];
- }
- FWARNING(("Image::getComponents: image %p has unknown pixel format 0x%x!",
- this, getPixelFormat()));
- return 0;
- }
- /*------------------------------ set object data --------------------------*/
- /*! method to set the image data. Use the doCopy parameter to specify, whether
- the method should copy or link the pixel data.
- */
- bool Image::set( UInt32 pF,
- Int32 w,
- Int32 h,
- Int32 d,
- Int32 mmS,
- Int32 fS,
- Time fD,
- const UChar8 *da,
- Int32 t,
- bool allocMem,
- Int32 sS)
- {
- setPixelFormat(pF );
- setWidth (osgMax ( 1, w ));
- setHeight (osgMax ( 1, h ));
- setDepth (osgMax ( 1, d ));
- setMipMapCount(osgMax ( 1, mmS));
- setSideCount (osgMax ( 1, sS ));
- setFrameCount (osgMax ( 1, fS ));
- setFrameDelay (fD);
- setDataType (t );
- calcMipmapOffsets();
- return createData(da, allocMem);
- }
- /*! method to set the image from another image object.
- Use the doCopy parameter to specify, whether
- the method should copy or link the pixel data.
- */
- bool Image::set(Image *image)
- {
- this->set(image->getPixelFormat(),
- image->getWidth (),
- image->getHeight (),
- image->getDepth (),
- image->getMipMapCount(),
- image->getFrameCount (),
- image->getFrameDelay (),
- image->getData (),
- image->getDataType (),
- true,
- image->getSideCount ());
- return true;
- }
- /*! method to set only the image pixel data, all parameter (e. pixelFormat
- width,height and depth) stay the same
- */
- bool Image::setData(const UChar8 *da)
- {
- if(da)
- {
- createData(da);
- }
- else
- {
- FWARNING(("Image::setData(Null) call\n"));
- }
- return (da ? true : false);
- }
- void Image::clearData(void)
- {
- editMFPixel()->clear();
- }
- /*! method to update just a subregion of the image data
- all paramter (e. pixelFormat,width,height,depth) stay the same
- */
- bool Image::setSubData( Int32 offX,
- Int32 offY,
- Int32 offZ,
- Int32 srcW,
- Int32 srcH,
- Int32 srcD,
- const UInt8 *src )
- {
- UChar8 *dest = editData();
- UInt64 lineSize;
- FDEBUG(( "Image::setSubData (%d %d %d) - (%d %d %d) - src %p\n",
- offX, offY, offZ, srcW, srcH, srcD, src ));
- if (hasCompressedData())
- {
- FFATAL (("Invalid Image::setSubData for compressed image\n"));
- return false;
- }
- if(!src || !dest)
- {
- FFATAL(("Invalid data pointer in Image::setSubData\n"));
- return false;
- }
- // determine the area to actually copy
- UInt32 xMin = osgMax(0, offX);
- UInt32 yMin = osgMax(0, offY);
- UInt32 zMin = osgMax(0, offZ);
- UInt32 xMax = osgMin(getWidth (), offX + srcW);
- UInt32 yMax = osgMin(getHeight(), offY + srcH);
- UInt32 zMax = osgMin(getDepth (), offZ + srcD);
- // fill the destination buffer with the subdata
- UInt32 destIdx, srcIdx = 0;
- for(UInt32 z = zMin; z < zMax; z++)
- {
- for(UInt32 y = yMin; y < yMax; y++)
- {
- lineSize = (xMax - xMin) * getBpp();
- destIdx = ((z * getHeight() + y) * getWidth() + xMin) * getBpp();
- memcpy (&dest[destIdx], &src[srcIdx], size_t(lineSize));
- srcIdx += Int32((srcW - (xMax - xMin)) * getBpp() + lineSize);
- }
- srcIdx += (srcH - (yMax - yMin)) * srcW * getBpp();
- }
- return true;
- }
- /*! The Image is not just a 2D container. The class can hold 3D (volume)
- and movie data. If we have 3D/singleFrame or 2D/multiFrame data without
- mipmaps we can flip between this two formats by just swapping the
- getFrameCount() and getDepth() values.
- */
- bool Image::flipDepthFrameData(void)
- {
- bool retCode = false;
- Int32 value;
- if((getMipMapCount() == 1) &&
- ((getFrameCount() == 1) || (getDepth() == 1)))
- {
- value = getFrameCount();
- setFrameCount(getDepth());
- setDepth (value );
- retCode = true;
- }
- else
- {
- FWARNING (("Cant flipDepthFrameData(); invalid data layout\n"));
- }
- return retCode;
- }
- /*! This method is used by the parser to fill the image with
- string pixel data. It expects the data in VRML PixelTexture Format.
- */
- bool Image::addValue(const char *value)
- {
- static Image *currentImage = 0;
- static UChar8 *currentData = 0;
- Int64 j;
- Int64 v;
- bool isHead = strchr(value, ' ') ? true : false;
- if (hasCompressedData())
- {
- FFATAL (("Invalid Image::addValue for compressed image\n"));
- return false;
- }
- // make sure we only read one image at a time
- if(currentImage == this)
- {
- if(isHead)
- {
- FDEBUG(("Start new read cycle in image::addValue()\n"));
- }
- }
- else
- {
- if(!isHead)
- {
- FFATAL(("Additional image date for different image\n"));
- }
- }
- currentImage = this;
- if(isHead == true)
- {
- Int32 width;
- Int32 height;
- Int32 pixelDepth;
- PixelFormat pf = Image::OSG_INVALID_PF;
- // read the head
- sscanf(value, "%d %d %d", &width, &height, &pixelDepth);
- FDEBUG(("Image::addValue() set: w/h/bpp: %d/%d/%d\n",
- width, height, pixelDepth));
- switch(getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- switch(pixelDepth)
- {
- case 1:
- pf = OSG::Image::OSG_L_PF;
- break;
- case 2:
- pf = OSG::Image::OSG_LA_PF;
- break;
- case 3:
- pf = OSG::Image::OSG_RGB_PF;
- break;
- case 4:
- pf = OSG::Image::OSG_RGBA_PF;
- break;
- default:
- pf = OSG::Image::OSG_INVALID_PF;
- FFATAL(("Invalid pixel depth: %d\n", pixelDepth));
- break;
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- switch(pixelDepth)
- {
- case 2:
- pf = OSG::Image::OSG_L_PF;
- break;
- case 4:
- pf = OSG::Image::OSG_LA_PF;
- break;
- case 6:
- pf = OSG::Image::OSG_RGB_PF;
- break;
- case 8:
- pf = OSG::Image::OSG_RGBA_PF;
- break;
- default:
- pf = OSG::Image::OSG_INVALID_PF;
- FFATAL(("Invalid pixel depth: %d\n", pixelDepth));
- break;
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- switch(pixelDepth)
- {
- case 4:
- pf = OSG::Image::OSG_L_PF;
- break;
- case 8:
- pf = OSG::Image::OSG_LA_PF;
- break;
- case 12:
- pf = OSG::Image::OSG_RGB_PF;
- break;
- case 16:
- pf = OSG::Image::OSG_RGBA_PF;
- break;
- default:
- pf = OSG::Image::OSG_INVALID_PF;
- FFATAL(("Invalid pixel depth: %d\n", pixelDepth));
- break;
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- switch(pixelDepth)
- {
- case 4:
- pf = OSG::Image::OSG_L_PF;
- break;
- case 8:
- pf = OSG::Image::OSG_LA_PF;
- break;
- case 12:
- pf = OSG::Image::OSG_RGB_PF;
- break;
- case 16:
- pf = OSG::Image::OSG_RGBA_PF;
- break;
- default:
- pf = OSG::Image::OSG_INVALID_PF;
- FFATAL(("Invalid pixel depth: %d\n", pixelDepth));
- break;
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- switch(pixelDepth)
- {
- case 2:
- pf = OSG::Image::OSG_L_PF;
- break;
- case 4:
- pf = OSG::Image::OSG_LA_PF;
- break;
- case 6:
- pf = OSG::Image::OSG_RGB_PF;
- break;
- case 8:
- pf = OSG::Image::OSG_RGBA_PF;
- break;
- default:
- pf = OSG::Image::OSG_INVALID_PF;
- FFATAL(("Invalid pixel depth: %d\n", pixelDepth));
- break;
- }
- break;
- case OSG_INT16_IMAGEDATA:
- case OSG_INT32_IMAGEDATA:
- {
- FFATAL((" 'addValue' NYI\n "));
- }
- break;
- default:
- setDataType(OSG_INVALID_IMAGEDATATYPE);
- FFATAL(("Invalid type of image data: %d\n", getDataType()));
- }
- if(pf != 0 && (width > 0) && (height > 0))
- {
- set(pf, width, height);
- currentData = editData();
- }
- else
- {
- currentData = NULL;
- }
- }
- else
- {
- if(currentData != NULL)
- {
- // add data
- // TODO; should we check the bounds, should be done by the parser
- v = strtoul(value, 0, strchr(value, 'x') ? 16 : 10);
- for(j = getBpp(); j--;)
- {
- *currentData++ = UChar8( (v >> (8 * j)) & 255 );
- }
- }
- }
- return currentData ? true : false;
- }
- /*! It is a simple method to reformat the image pixelFormat (not the size).
- So you can for example convert a RGBA to RGB or RGB to Grey image.
- */
- bool Image::reformat(const Image::PixelFormat pixelFormat,
- Image *destination,
- Int32 iCompressionFlags)
- {
- UChar8 *data = NULL;
- const UChar8 *sourceData = NULL;
- UInt32 srcI, destI, destSize = 0;
- UInt32 sum;
- Real64 sumReal;
- ImageUnrecPtr dest(destination);
- if (hasCompressedData())
- {
- FFATAL (("Invalid Image::reformat for compressed image\n"));
- return false;
- }
- if(destination == NULL)
- {
- dest = Image::create();
- }
- FINFO(("Try to reformat image from pixelDepth %d to %d\n",
- getPixelFormat(),
- pixelFormat ));
- if(iCompressionFlags == 0)
- {
- iCompressionFlags = (osgsquish::kColourMetricPerceptual |
- osgsquish::kColourRangeFit );
- }
- iCompressionFlags &= ~0x07;
- // TODO !!! code all the cases !!!
- if(getSize() != 0 &&
- pixelFormat != OSG_INVALID_PF &&
- (destination != 0 || (pixelFormat != static_cast<Image::PixelFormat>(getPixelFormat()))))
- {
- dest->set(pixelFormat,
- getWidth (),
- getHeight (),
- getDepth (),
- getMipMapCount(),
- getFrameCount (),
- getFrameDelay (),
- NULL,
- getDataType (),
- true,
- getSideCount ());
- sourceData = getData();
- data = dest->editData();
- destSize = dest->getSize();
- const UInt16 *sourceDataUC16 =
- reinterpret_cast<const UInt16 *>(sourceData);
- UInt16 *destDataUC16 = reinterpret_cast<UInt16 *>(data);
- const UInt32 *sourceDataUC32 =
- reinterpret_cast<const UInt32 *>(sourceData);
- UInt32 *destDataUC32 = reinterpret_cast<UInt32 *>(data);
- const Real32 *sourceDataF32 =
- reinterpret_cast<const Real32 *>(sourceData);
- Real32 *destDataF32 = reinterpret_cast<Real32 *>(data);
- const Real16 *sourceDataH16 =
- reinterpret_cast<const Real16 *>(sourceData);
- Real16 *destDataH16 = reinterpret_cast<Real16 *>(data);
- if(data)
- {
- switch (getPixelFormat())
- {
- //-----------------------------------------------------
- case OSG_A_PF:
- switch (pixelFormat)
- {
- case OSG_A_PF:
- case OSG_I_PF:
- case OSG_L_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- case OSG_UINT16_IMAGEDATA:
- case OSG_UINT32_IMAGEDATA:
- case OSG_FLOAT32_IMAGEDATA:
- case OSG_FLOAT16_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
-
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- case OSG_LA_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
-
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
-
- case OSG_RGB_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
-
- case OSG_RGBA_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- //-----------------------------------------------------
- case OSG_I_PF:
- switch (pixelFormat)
- {
- case OSG_A_PF:
- case OSG_I_PF:
- case OSG_L_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_UINT16_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_UINT32_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_FLOAT32_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_FLOAT16_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- case OSG_LA_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- case OSG_RGB_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- case OSG_RGBA_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- //-----------------------------------------------------
- case OSG_L_PF:
- switch (pixelFormat)
- {
- case OSG_A_PF:
- case OSG_I_PF:
- case OSG_L_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_UINT16_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_UINT32_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_FLOAT32_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- case OSG_FLOAT16_IMAGEDATA:
- memcpy (data, getData(), destSize);
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- case OSG_LA_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- break;
- }
- break;
- case OSG_RGB_PF:
- switch (getDataType())
- {
- case OSG_UINT8_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize;)
- {
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI];
- data[destI++] = sourceData[srcI++];
- }
- break;
- case OSG_UINT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI];
- destDataUC16[destI++] = sourceDataUC16[srcI++];
- }
- break;
- case OSG_UINT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI];
- destDataUC32[destI++] = sourceDataUC32[srcI++];
- }
- break;
- case OSG_FLOAT32_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI];
- destDataF32[destI++] = sourceDataF32[srcI++];
- }
- break;
- case OSG_FLOAT16_IMAGEDATA:
- for (srcI = destI = 0; destI < destSize/getComponentSize();)
- {
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI];
- destDataH16[destI++] = sourceDataH16[srcI++];
- }
- break;
- default:
- FWARNING (( "Invalid IMAGE_DATA_TYPE\n" ));
- …
Large files files are truncated, but you can click here to view the full file