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 typedef PNODE
* PPNODE
;
46 class BitmapReadAccess
;
48 class VCL_PLUGIN_PUBLIC Octree
57 PNODE pReduce
[ OCTREE_BITS
+ 1 ];
59 ImpNodeCache
* pNodeCache
;
60 const BitmapReadAccess
* pAcc
;
65 void CreatePalette( PNODE pNode
);
66 void GetPalIndex( PNODE pNode
);
68 SAL_DLLPRIVATE
void ImplCreateOctree();
69 SAL_DLLPRIVATE
void ImplDeleteOctree( PPNODE ppNode
);
70 SAL_DLLPRIVATE
void ImplAdd( PPNODE ppNode
);
71 SAL_DLLPRIVATE
void ImplReduce();
75 Octree( const BitmapReadAccess
& rReadAcc
, sal_uLong nColors
);
78 inline const BitmapPalette
& GetPalette();
79 inline sal_uInt16
GetBestPaletteIndex( const BitmapColor
& rColor
);
82 inline const BitmapPalette
& Octree::GetPalette()
84 aPal
.SetEntryCount( (sal_uInt16
) nLeafCount
);
86 CreatePalette( pTree
);
90 inline sal_uInt16
Octree::GetBestPaletteIndex( const BitmapColor
& rColor
)
92 pColor
= &(BitmapColor
&) rColor
;
99 class VCL_PLUGIN_PUBLIC InverseColorMap
105 const sal_uLong nBits
;
107 SAL_DLLPRIVATE
void ImplCreateBuffers( const sal_uLong nMax
);
111 explicit InverseColorMap( const BitmapPalette
& rPal
);
114 inline sal_uInt16
GetBestPaletteIndex( const BitmapColor
& rColor
);
117 inline sal_uInt16
InverseColorMap::GetBestPaletteIndex( const BitmapColor
& rColor
)
119 return pMap
[ ( ( (sal_uLong
) rColor
.GetRed() >> nBits
) << OCTREE_BITS_1
) |
120 ( ( (sal_uLong
) rColor
.GetGreen() >> nBits
) << OCTREE_BITS
) |
121 ( (sal_uLong
) rColor
.GetBlue() >> nBits
) ];
124 #endif // INCLUDED_VCL_INC_OCTREE_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */