From 0b8d043fb9f4a185f014c934d48b05364cc94296 Mon Sep 17 00:00:00 2001 From: Fulvio Satta Date: Sun, 1 Feb 2009 01:14:23 +0100 Subject: [PATCH] Readapt the comments for Image --- src/Image.cpp | 30 ++++++++++++------------------ src/Image.h | 44 ++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 44 deletions(-) diff --git a/src/Image.cpp b/src/Image.cpp index 6dc8916..4bc9479 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -2,14 +2,14 @@ * * If you want contact me, send an email to Yota_VGA@users.sf.net * - * This file is part of Cassata + * This file is part of Biscotto * - * Cassata is free software; you can redistribute it and/or modify + * Biscotto 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. * - * Cassata is distributed in the hope that it will be useful, + * Biscotto 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. @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include //Per memset -#include #include "Image.h" +#include +#include //For memset using namespace Imf; using namespace boost; @@ -30,24 +30,22 @@ using namespace std; Image::Image(const string &filename, unsigned int w, unsigned int h, enum Action action) : data(new RGBA[w * h]), m_w(w), m_h(h) { - /* Creo un header */ + /* Make an header */ Header header(w, h); - /* Gli inserisco i canali */ + /* Channel inserting */ header.channels().insert("R", Channel(FLOAT)); header.channels().insert("G", Channel(FLOAT)); header.channels().insert("B", Channel(FLOAT)); header.channels().insert("A", Channel(FLOAT)); - /* Creo il file */ + /* Make the file */ file = auto_ptr(new OutputFile(filename.c_str(), header)); - /* Creo un framebuffer */ + /* Make a framebuffer */ FrameBuffer framebuffer; - /* Assegno al framebuffer gli slice dei dati corrispondenti ai vari - * colori - */ + /* Assign the color corrispondent slices at the framebuffer */ framebuffer.insert("R", Slice(FLOAT, (char *)&data[0].r, sizeof(struct RGBA) * h, sizeof(struct RGBA))); framebuffer.insert("G", Slice(FLOAT, (char *)&data[0].g, @@ -57,23 +55,19 @@ Image::Image(const string &filename, unsigned int w, unsigned int h, framebuffer.insert("A", Slice(FLOAT, (char *)&data[0].a, sizeof(struct RGBA) * h, sizeof(struct RGBA))); - /* Azzero il contenuto dell'immagine (nero puro e completamente - * trasparente - */ + /* Clear the image data (black and transparent) */ memset(data.get(), 0, sizeof(RGBA) * w * h); - /* setto il framebuffer nel file */ + /* Join the framebuffer with the file */ file->setFrameBuffer(framebuffer); } void Image::writeLines(unsigned int n) { - /* Scrivo n linee */ file->writePixels(n); } void Image::writeLine() { - /* Scrivo una linea */ writeLines(1); } diff --git a/src/Image.h b/src/Image.h index 00a9be6..60b6e48 100644 --- a/src/Image.h +++ b/src/Image.h @@ -2,14 +2,14 @@ * * If you want contact me, send an email to Yota_VGA@users.sf.net * - * This file is part of Cassata + * This file is part of Biscotto * - * Cassata is free software; you can redistribute it and/or modify + * Biscotto 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. * - * Cassata is distributed in the hope that it will be useful, + * Biscotto 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. @@ -21,17 +21,17 @@ #ifndef IMAGE_H #define IMAGE_H -#include //Per auto_ptr -#include //Per scoped_array +#include //For auto_ptr +#include //For scoped_array #include #include -/* Classe per leggere e scrivere un'immagine */ -//TODO: Eseguire la lettura di un'immagine +/* Read and write in an image */ +//TODO: Image reading class Image { public: - /* Un pixel */ + /* A pixel */ struct RGBA { float r, g, b, a; @@ -65,49 +65,41 @@ class Image }; protected: - /* Puntatori usati all'interno della classe. Scope automatico */ + /* Pointers used in the class. Automatic remotion */ boost::scoped_array data; std::auto_ptr file; - /* Dimensioni dell'immagine */ + /* Size of the image */ unsigned int m_w, m_h; public: - /* Azioni compibili con la classe (attualmente solo la creazione di - * un'immagine) - */ + /* Actions for the class (only image creation for now) */ enum Action {Create}; - /* Costruttore che accetta il nome del file, le dimensioni - * dell'immagine e l'azione da compiere - */ + /* Accept file name, the size of the image and the action */ Image(const std::string &filename, unsigned int w, unsigned int h, enum Action action); - /* Scrive le successive n linee dopo quelle che sono state scritte - * fino ad ora, dall'alto verso il basso - */ + /* Write the next n lines, from top to bottom */ void writeLines(unsigned int n); - /* Come writeLines ma scrive una sola linea */ + /* Like writeLines(1) */ void writeLine(); - /* Prende il puntatore ad una colonna di pixel. - * Notare che รจ possibile accedere alla struttura RGBA di un pixel - * usando image[x][y]. - */ + /* Get the pointer of a pixel column. + * It is possible access to the RGBA structure with image[x][y] */ inline RGBA *operator[](unsigned int x) { return &data[x * m_h]; } - /* Funzione equivalente alla precedente ma per oggetti const - */ + /* Like the previous, but for consts */ inline const RGBA *operator[](unsigned int x) const { return &data[x * m_h]; } + /* Sizes of the image */ inline unsigned int w() const { return m_w; -- 2.11.4.GIT