Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:05

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Image_PixMapTypedData_Header
0015 #define _Image_PixMapTypedData_Header
0016 
0017 #include <Image_PixMapData.hxx>
0018 
0019 //! Structure to manage image buffer with predefined pixel type.
0020 template<typename PixelType_t>
0021 class Image_PixMapTypedData : public Image_PixMapData
0022 {
0023 public:
0024   //! Empty constructor.
0025   Image_PixMapTypedData() {}
0026 
0027   //! Initializer.
0028   bool Init (const Handle(NCollection_BaseAllocator)& theAlloc,
0029              Standard_Size  theSizeX,
0030              Standard_Size  theSizeY,
0031              Standard_Size  theSizeRowBytes = 0,
0032              Standard_Byte* theDataPtr = 0)
0033   {
0034     const Standard_Size aSizeBPP = sizeof(PixelType_t);
0035     return Image_PixMapData::Init (theAlloc, aSizeBPP, theSizeX, theSizeY, theSizeRowBytes, theDataPtr);
0036   }
0037 
0038   //! Reset all values to specified one.
0039   void Init (const PixelType_t& theValue)
0040   {
0041     for (Standard_Size aRowIter = 0; aRowIter < SizeY; ++aRowIter)
0042     {
0043       for (Standard_Size aColIter = 0; aColIter < SizeX; ++aColIter)
0044       {
0045         ChangeValue (aRowIter, aColIter) = theValue;
0046       }
0047     }
0048   }
0049 
0050   //! @return data pointer to requested row (first column).
0051   const PixelType_t* Row (Standard_Size theRow) const { return (const PixelType_t* )Image_PixMapData::Row (theRow); }
0052 
0053   //! @return data pointer to requested row (first column).
0054   PixelType_t* ChangeRow (Standard_Size theRow) { return (PixelType_t* )Image_PixMapData::ChangeRow (theRow); }
0055 
0056   //! @return data pointer to requested position.
0057   const PixelType_t& Value (Standard_Size theRow, Standard_Size theCol) const { return *(const PixelType_t* )Image_PixMapData::Value (theRow, theCol); }
0058 
0059   //! @return data pointer to requested position.
0060   PixelType_t& ChangeValue (Standard_Size theRow, Standard_Size theCol) { return *(PixelType_t* )Image_PixMapData::ChangeValue (theRow, theCol); }
0061 
0062 };
0063 
0064 #endif // _Image_PixMapTypedData_Header