Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:03:44

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() = default;
0026 
0027   //! Initializer.
0028   bool Init(const occ::handle<NCollection_BaseAllocator>& theAlloc,
0029             size_t                                        theSizeX,
0030             size_t                                        theSizeY,
0031             size_t                                        theSizeRowBytes = 0,
0032             uint8_t*                                      theDataPtr      = nullptr)
0033   {
0034     const size_t aSizeBPP = sizeof(PixelType_t);
0035     return Image_PixMapData::Init(theAlloc,
0036                                   aSizeBPP,
0037                                   theSizeX,
0038                                   theSizeY,
0039                                   theSizeRowBytes,
0040                                   theDataPtr);
0041   }
0042 
0043   //! Reset all values to specified one.
0044   void Init(const PixelType_t& theValue)
0045   {
0046     for (size_t aRowIter = 0; aRowIter < SizeY; ++aRowIter)
0047     {
0048       for (size_t aColIter = 0; aColIter < SizeX; ++aColIter)
0049       {
0050         ChangeValue(aRowIter, aColIter) = theValue;
0051       }
0052     }
0053   }
0054 
0055   //! @return data pointer to requested row (first column).
0056   const PixelType_t* Row(size_t theRow) const
0057   {
0058     return (const PixelType_t*)Image_PixMapData::Row(theRow);
0059   }
0060 
0061   //! @return data pointer to requested row (first column).
0062   PixelType_t* ChangeRow(size_t theRow)
0063   {
0064     return (PixelType_t*)Image_PixMapData::ChangeRow(theRow);
0065   }
0066 
0067   //! @return data pointer to requested position.
0068   const PixelType_t& Value(size_t theRow, size_t theCol) const
0069   {
0070     return *(const PixelType_t*)Image_PixMapData::Value(theRow, theCol);
0071   }
0072 
0073   //! @return data pointer to requested position.
0074   PixelType_t& ChangeValue(size_t theRow, size_t theCol)
0075   {
0076     return *(PixelType_t*)Image_PixMapData::ChangeValue(theRow, theCol);
0077   }
0078 };
0079 
0080 #endif // _Image_PixMapTypedData_Header