bump product version to 4.1.6.2
[LibreOffice.git] / include / basegfx / raster / bpixelraster.hxx
blobed7ac931d805618efe9b8beae2d28b6ae54ada46
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _BGFX_RASTER_BPIXELRASTER_HXX
21 #define _BGFX_RASTER_BPIXELRASTER_HXX
23 #include <algorithm>
24 #include <string.h>
25 #include <sal/types.h>
26 #include <basegfx/pixel/bpixel.hxx>
27 #include <basegfx/basegfxdllapi.h>
29 //////////////////////////////////////////////////////////////////////////////
30 // predeclarations
32 //////////////////////////////////////////////////////////////////////////////
34 namespace basegfx
36 class BPixelRaster
38 private:
39 // do not allow copy constructor and assignment operator
40 BPixelRaster(const BPixelRaster&);
41 BPixelRaster& operator=(const BPixelRaster&);
43 protected:
44 sal_uInt32 mnWidth;
45 sal_uInt32 mnHeight;
46 sal_uInt32 mnCount;
47 BPixel* mpContent;
49 public:
50 // reset
51 void reset()
53 memset(mpContent, 0, sizeof(BPixel) * mnCount);
56 // constructor/destructor
57 BPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
58 : mnWidth(nWidth),
59 mnHeight(nHeight),
60 mnCount(nWidth * nHeight),
61 mpContent(new BPixel[mnCount])
63 reset();
66 ~BPixelRaster()
68 delete [] mpContent;
71 // coordinate calcs between X/Y and span
72 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); }
76 // data access read
77 sal_uInt32 getWidth() const { return mnWidth; }
78 sal_uInt32 getHeight() const { return mnHeight; }
79 sal_uInt32 getCount() const { return mnCount; }
81 // data access read only
82 const BPixel& getBPixel(sal_uInt32 nIndex) const
84 assert(nIndex < mnCount); //Access out of range
85 return mpContent[nIndex];
88 // data access read/write
89 BPixel& getBPixel(sal_uInt32 nIndex)
91 assert(nIndex < mnCount); //Access out of range
92 return mpContent[nIndex];
95 } // end of namespace basegfx
97 #endif /* _BGFX_RASTER_BPIXELRASTER_HXX */
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */