# SbImage.h

    00001 #ifndef COIN_SBIMAGE_H
    00002 #define COIN_SBIMAGE_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/SbVec2s.h>
    00028 #include <Inventor/SbVec3s.h>
    00029 #include <Inventor/SbString.h>
    00030 #include <stddef.h> // for NULL
    00031
    00032 class SbImage;
    00033
    00034 typedef SbBool SbImageScheduleReadCB(const SbString &, SbImage *, void *);
    00035
    00036 class COIN_DLL_API SbImage {
    00037 public:
    00038   SbImage(void);
    00039   SbImage(const unsigned char * bytes,
    00040           const SbVec2s & size, const int bytesperpixel);
    00041   SbImage(const unsigned char * bytes,
    00042           const SbVec3s & size, const int bytesperpixel);
    00043   ~SbImage();
    00044
    00045   void setValue(const SbVec2s & size, const int bytesperpixel,
    00046                 const unsigned char * bytes);
    00047   void setValue(const SbVec3s & size, const int bytesperpixel,
    00048                 const unsigned char * bytes);
    00049   void setValuePtr(const SbVec2s & size, const int bytesperpixel,
    00050                    const unsigned char * bytes);
    00051   void setValuePtr(const SbVec3s & size, const int bytesperpixel,
    00052                    const unsigned char * bytes);
    00053   unsigned char * getValue(SbVec2s & size, int & bytesperpixel) const;
    00054   unsigned char * getValue(SbVec3s & size, int & bytesperpixel) const;
    00055   SbVec3s getSize(void) const;
    00056
    00057   SbBool readFile(const SbString & filename,
    00058                   const SbString * const * searchdirectories = NULL,
    00059                   const int numdirectories = 0);
    00060
    00061   int operator==(const SbImage & image) const;
    00062   int operator!=(const SbImage & image) const {
    00063     return ! operator == (image);
    00064   }
    00065   SbImage & operator=(const SbImage & image);
    00066
    00067   static SbString searchForFile(const SbString & basename,
    00068                                 const SbString * const * dirlist,
    00069                                 const int numdirs);
    00070
    00071   SbBool hasData(void) const;
    00072
    00073 private:
    00074
    00075   class SbImageP * pimpl;
    00076
    00077 public:
    00078
    00079   // methods for delaying image loading until it is actually needed.
    00080   void readLock(void) const;
    00081   void readUnlock(void) const;
    00082
    00083   SbBool scheduleReadFile(SbImageScheduleReadCB * cb,
    00084                           void * closure,
    00085                           const SbString & filename,
    00086                           const SbString * const * searchdirectories = NULL,
    00087                           const int numdirectories = 0);
    00088 };
    00089
    00090 #endif // !COIN_SBIMAGE_H