Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / image.h
blob0dcc14ef7da84520b86600b2741e82d345691fc7
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 INCLUDED_VCL_INC_IMAGE_H
21 #define INCLUDED_VCL_INC_IMAGE_H
23 #include <vcl/bitmapex.hxx>
25 #include <unordered_map>
27 // - ImplImageBmp -
29 class ImplImageBmp
31 public:
33 ImplImageBmp();
34 ~ImplImageBmp();
36 void Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight,sal_uInt16 nInitSize );
37 void ColorTransform();
38 void Draw( sal_uInt16 nPos, OutputDevice* pDev, const Point& rPos, DrawImageFlags nStyle, const Size* pSize = NULL );
40 private:
42 BitmapEx maBmpEx;
43 BitmapChecksum maBitmapChecksum;
45 BitmapEx maDisabledBmpEx;
46 BitmapEx* mpDisplayBmp;
47 Size maSize;
48 sal_uInt8* mpInfoAry;
49 sal_uInt16 mnSize;
51 void ImplUpdateDisplayBmp( OutputDevice* pOutDev );
52 void ImplUpdateDisabledBmpEx( int nPos );
54 private:
55 ImplImageBmp( const ImplImageBmp& ) SAL_DELETED_FUNCTION;
56 void operator=( const ImplImageBmp& ) SAL_DELETED_FUNCTION;
59 // - ImageTypes -
61 enum ImageType { IMAGETYPE_BITMAP, IMAGETYPE_IMAGE };
63 // - ImplImageList -
65 struct ImageAryData
67 OUString maName;
68 // Images identified by either name, or by id
69 sal_uInt16 mnId;
70 BitmapEx maBitmapEx;
72 ImageAryData( const OUString &aName,
73 sal_uInt16 nId, const BitmapEx &aBitmap );
74 ImageAryData( const ImageAryData& rData );
75 ~ImageAryData();
77 bool IsLoadable() { return maBitmapEx.IsEmpty() && !maName.isEmpty(); }
78 void Load(const OUString &rPrefix);
80 ImageAryData& operator=( const ImageAryData& rData );
83 struct ImplImageList
85 typedef std::vector<ImageAryData *> ImageAryDataVec;
86 typedef std::unordered_map< OUString, ImageAryData *, OUStringHash >
87 ImageAryDataNameHash;
89 ImageAryDataVec maImages;
90 ImageAryDataNameHash maNameHash;
91 OUString maPrefix;
92 Size maImageSize;
93 sal_uIntPtr mnRefCount;
95 ImplImageList();
96 ImplImageList( const ImplImageList &aSrc );
97 ~ImplImageList();
99 void AddImage( const OUString &aName,
100 sal_uInt16 nId, const BitmapEx &aBitmapEx );
101 void RemoveImage( sal_uInt16 nPos );
104 // - ImplImageRefData -
106 struct ImplImageRefData
108 ImplImageList* mpImplData;
109 sal_uInt16 mnIndex;
111 ImplImageRefData() {} // Um Warning zu umgehen
112 ~ImplImageRefData();
114 bool IsEqual( const ImplImageRefData& rData );
117 // - ImpImageData -
119 struct ImplImageData
121 ImplImageBmp* mpImageBitmap;
122 BitmapEx maBmpEx;
124 ImplImageData( const BitmapEx& rBmpEx );
125 ~ImplImageData();
127 bool IsEqual( const ImplImageData& rData );
130 // - ImplImage -
132 struct ImplImage
134 sal_uIntPtr mnRefCount;
135 // TODO: use inheritance to get rid of meType+mpData
136 void* mpData;
137 ImageType meType;
139 ImplImage();
140 ~ImplImage();
142 private:
143 ImplImage( const ImplImage&) SAL_DELETED_FUNCTION;
144 void operator=( const ImplImage&) SAL_DELETED_FUNCTION;
147 #endif // INCLUDED_VCL_INC_IMAGE_H
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */