LCOV - code coverage report
Current view: top level - include/basegfx/raster - bpixelraster.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 18 0.0 %
Date: 2014-04-14 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_BASEGFX_RASTER_BPIXELRASTER_HXX
      21             : #define INCLUDED_BASEGFX_RASTER_BPIXELRASTER_HXX
      22             : 
      23             : #include <algorithm>
      24             : #include <string.h>
      25             : #include <sal/types.h>
      26             : #include <basegfx/pixel/bpixel.hxx>
      27             : #include <basegfx/basegfxdllapi.h>
      28             : 
      29             : 
      30             : // predeclarations
      31             : 
      32             : 
      33             : 
      34             : namespace basegfx
      35             : {
      36             :     class BPixelRaster
      37             :     {
      38             :     private:
      39             :         // do not allow copy constructor and assignment operator
      40             :         BPixelRaster(const BPixelRaster&);
      41             :         BPixelRaster& operator=(const BPixelRaster&);
      42             : 
      43             :     protected:
      44             :         sal_uInt32                  mnWidth;
      45             :         sal_uInt32                  mnHeight;
      46             :         sal_uInt32                  mnCount;
      47             :         BPixel*                     mpContent;
      48             : 
      49             :     public:
      50             :         // reset
      51           0 :         void reset()
      52             :         {
      53           0 :             memset(mpContent, 0, sizeof(BPixel) * mnCount);
      54           0 :         }
      55             : 
      56             :         // constructor/destructor
      57           0 :         BPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
      58             :         :   mnWidth(nWidth),
      59             :             mnHeight(nHeight),
      60           0 :             mnCount(nWidth * nHeight),
      61           0 :             mpContent(new BPixel[mnCount])
      62             :         {
      63           0 :             reset();
      64           0 :         }
      65             : 
      66           0 :         ~BPixelRaster()
      67             :         {
      68           0 :             delete [] mpContent;
      69           0 :         }
      70             : 
      71             :         // coordinate calcs between X/Y and span
      72           0 :         sal_uInt32 getIndexFromXY(sal_uInt32 nX, sal_uInt32 nY) const { return (nX + (nY * mnWidth)); }
      73             :         sal_uInt32 getXFromIndex(sal_uInt32 nIndex) const { return (nIndex % mnWidth); }
      74             :         sal_uInt32 getYFromIndex(sal_uInt32 nIndex) const { return (nIndex / mnWidth); }
      75             : 
      76             :         // data access read
      77           0 :         sal_uInt32 getWidth() const { return mnWidth; }
      78           0 :         sal_uInt32 getHeight() const { return mnHeight; }
      79             :         sal_uInt32 getCount() const { return mnCount; }
      80             : 
      81             :         // data access read only
      82           0 :         const BPixel& getBPixel(sal_uInt32 nIndex) const
      83             :         {
      84             :             assert(nIndex < mnCount); //Access out of range
      85           0 :             return mpContent[nIndex];
      86             :         }
      87             : 
      88             :         // data access read/write
      89           0 :         BPixel& getBPixel(sal_uInt32 nIndex)
      90             :         {
      91             :             assert(nIndex < mnCount); //Access out of range
      92           0 :             return mpContent[nIndex];
      93             :         }
      94             :     };
      95             : } // end of namespace basegfx
      96             : 
      97             : #endif // INCLUDED_BASEGFX_RASTER_BPIXELRASTER_HXX
      98             : 
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10