summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/image/image.tcc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/image/image.tcc')
-rw-r--r--2005/i/robert/src/image/image.tcc121
1 files changed, 121 insertions, 0 deletions
diff --git a/2005/i/robert/src/image/image.tcc b/2005/i/robert/src/image/image.tcc
new file mode 100644
index 0000000..5baed09
--- /dev/null
+++ b/2005/i/robert/src/image/image.tcc
@@ -0,0 +1,121 @@
+// image.tcc
+// robert - programme du robot 2005. {{{
+//
+// Copyright (C) 2005 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2005.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+
+/// Constructeur de copie, copy-on-write.
+inline
+Image::Image (const Image &image)
+ : rep_ (image.rep_->copyRef ())
+{
+}
+
+/// Destructeur.
+inline
+Image::~Image (void)
+{
+ rep_->release ();
+}
+
+/// Récupère la taille de l'image.
+inline
+void
+Image::getSize (int &width, int &height) const
+{
+ width = rep_->width_;
+ height = rep_->height_;
+}
+
+/// Retourne le format des pixels.
+inline
+Image::PixelFormat
+Image::getPixelFormat (void) const
+{
+ return rep_->pixelFormat_;
+}
+
+/// Retourne le nombre d'octets par pixels.
+inline
+unsigned
+Image::getBytePerPixel (void) const
+{
+ return rep_->bpp_;
+}
+
+/// Retourne le nombre d'octets par pixels pour un format donnée.
+inline
+unsigned
+Image::getBytePerPixel (Image::PixelFormat pixelFormat)
+{
+ return pixelFormat == Image::yuv422 ? 2 : 3;
+}
+
+/// Retourne la taille du tampon mémoire.
+inline
+unsigned
+Image::getBufSize (void) const
+{
+ return rep_->bufSize_;
+}
+
+/// Retourne la taille du tampon mémoire pour une image donnée.
+inline
+unsigned
+Image::getBufSize (int width, int height, Image::PixelFormat pixelFormat)
+{
+ return width * height * Image::getBytePerPixel (pixelFormat);
+}
+
+/// Récupère un pointeur vers l'image.
+inline
+const uint8_t *
+Image::getBuf (void) const
+{
+ return rep_->getBuf ();
+}
+
+/// Récupère un pointeur mutable vers l'image. Déclenche éventuellement
+/// une copie.
+inline
+uint8_t *
+Image::getMutableBuf (void)
+{
+ if (rep_->references_ != 0)
+ rep_ = rep_->copy ();
+ return rep_->getBuf ();
+}
+
+/// Récupère le buffer.
+inline
+uint8_t *
+Image::Rep::getBuf (void)
+{
+ return reinterpret_cast<uint8_t *> (this + 1);
+}
+
+/// Constructeur, interdit.
+inline
+Image::Rep::Rep (void)
+{
+}
+