Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SbImage.h
Go to the documentation of this file.
1 #ifndef COIN_SBIMAGE_H
2 #define COIN_SBIMAGE_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/SbVec2s.h>
37 #include <Inventor/SbVec3s.h>
38 #include <Inventor/SbString.h>
39 #include <stddef.h> // for NULL
40 
41 class SbImage;
42 
43 typedef SbBool SbImageScheduleReadCB(const SbString &, SbImage *, void *);
44 typedef SbBool SbImageReadImageCB(const SbString &, SbImage *, void *);
45 
46 class COIN_DLL_API SbImage {
47 public:
48  SbImage(void);
49  SbImage(const unsigned char * bytes,
50  const SbVec2s & size, const int bytesperpixel);
51  SbImage(const unsigned char * bytes,
52  const SbVec3s & size, const int bytesperpixel);
53  SbImage(const SbImage & image);
54  ~SbImage();
55 
56  void setValue(const SbVec2s & size, const int bytesperpixel,
57  const unsigned char * bytes);
58  void setValue(const SbVec3s & size, const int bytesperpixel,
59  const unsigned char * bytes);
60  void setValuePtr(const SbVec2s & size, const int bytesperpixel,
61  const unsigned char * bytes);
62  void setValuePtr(const SbVec3s & size, const int bytesperpixel,
63  const unsigned char * bytes);
64  unsigned char * getValue(SbVec2s & size, int & bytesperpixel) const;
65  unsigned char * getValue(SbVec3s & size, int & bytesperpixel) const;
66  SbVec3s getSize(void) const;
67 
68  SbBool readFile(const SbString & filename,
69  const SbString * const * searchdirectories = NULL,
70  const int numdirectories = 0);
71 
72  int operator==(const SbImage & image) const;
73  int operator!=(const SbImage & image) const {
74  return ! operator == (image);
75  }
76  SbImage & operator=(const SbImage & image);
77 
78  static void addReadImageCB(SbImageReadImageCB * cb, void * closure);
79  static void removeReadImageCB(SbImageReadImageCB * cb, void * closure);
80 
81  static SbString searchForFile(const SbString & basename,
82  const SbString * const * dirlist,
83  const int numdirs);
84 
85  SbBool hasData(void) const;
86 
87 private:
88 
89  class SbImageP * pimpl;
90 
91 public:
92 
93  // methods for delaying image loading until it is actually needed.
94  void readLock(void) const;
95  void readUnlock(void) const;
96 
97  SbBool scheduleReadFile(SbImageScheduleReadCB * cb,
98  void * closure,
99  const SbString & filename,
100  const SbString * const * searchdirectories = NULL,
101  const int numdirectories = 0);
102 };
103 
104 #endif // !COIN_SBIMAGE_H
SbBool SbImageScheduleReadCB(const SbString &, SbImage *, void *)
Definition: SbImage.h:43
int operator!=(const SbImage &image) const
Definition: SbImage.h:73
SbBool SbImageReadImageCB(const SbString &, SbImage *, void *)
Definition: SbImage.h:44
The SbVec3s class is a 3 dimensional vector with short integer coordinates.This vector class provides...
Definition: SbVec3s.h:51
The SbImage class is an abstract datatype for 2D and 3D images.Be aware that this class is an extensi...
Definition: SbImage.h:46
The SbString class is a string class with convenience functions for string operations.This is the class used for storing and working with character strings. It automatically takes care of supporting all the "bookkeeping" tasks usually associated with working with character strings, like memory allocation and deallocation etc.
Definition: SbString.h:52
The SbVec2s class is a 2 dimensional vector with short integer coordinates.This vector class is used ...
Definition: SbVec2s.h:51