1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_VCL_INC_OCTREE_HXX
21 #define INCLUDED_VCL_INC_OCTREE_HXX
23 #include <vcl/salbtype.hxx>
24 #include <vcl/dllapi.h>
27 #define OCTREE_BITS_1 10
29 typedef struct OctreeNode
35 OctreeNode
* pChild
[ 8 ];
37 OctreeNode
* pNextInCache
;
43 class BitmapReadAccess
;
45 class VCL_PLUGIN_PUBLIC Octree
48 void CreatePalette( NODE
* pNode
);
49 void GetPalIndex( NODE
* pNode
);
51 SAL_DLLPRIVATE
void ImplDeleteOctree( NODE
** ppNode
);
52 SAL_DLLPRIVATE
void ImplAdd( NODE
** ppNode
);
53 SAL_DLLPRIVATE
void ImplReduce();
61 NODE
* pReduce
[ OCTREE_BITS
+ 1 ];
63 ImpNodeCache
* pNodeCache
;
64 const BitmapReadAccess
* pAcc
;
69 Octree( const BitmapReadAccess
& rReadAcc
, sal_uLong nColors
);
72 inline const BitmapPalette
& GetPalette();
73 inline sal_uInt16
GetBestPaletteIndex( const BitmapColor
& rColor
);
76 inline const BitmapPalette
& Octree::GetPalette()
78 aPal
.SetEntryCount( (sal_uInt16
) nLeafCount
);
80 CreatePalette( pTree
);
84 inline sal_uInt16
Octree::GetBestPaletteIndex( const BitmapColor
& rColor
)
86 pColor
= &(BitmapColor
&) rColor
;
93 class VCL_PLUGIN_PUBLIC InverseColorMap
99 const sal_uLong nBits
;
101 SAL_DLLPRIVATE
void ImplCreateBuffers( const sal_uLong nMax
);
105 explicit InverseColorMap( const BitmapPalette
& rPal
);
108 inline sal_uInt16
GetBestPaletteIndex( const BitmapColor
& rColor
);
111 inline sal_uInt16
InverseColorMap::GetBestPaletteIndex( const BitmapColor
& rColor
)
113 return pMap
[ ( ( (sal_uLong
) rColor
.GetRed() >> nBits
) << OCTREE_BITS_1
) |
114 ( ( (sal_uLong
) rColor
.GetGreen() >> nBits
) << OCTREE_BITS
) |
115 ( (sal_uLong
) rColor
.GetBlue() >> nBits
) ];
118 #endif // INCLUDED_VCL_INC_OCTREE_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */