1/*
2
3Image Cache Item.
4
5Copyright (c) 2003 OpenBeOS.
6
7Author:
8	Michael Pfeiffer
9
10Permission is hereby granted, free of charge, to any person obtaining a copy of
11this software and associated documentation files (the "Software"), to deal in
12the Software without restriction, including without limitation the rights to
13use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14of the Software, and to permit persons to whom the Software is furnished to do
15so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE.
27
28*/
29
30#ifndef _IMAGE_CACHE_ITEM_H
31#define _IMAGE_CACHE_ITEM_H
32
33#include "pdflib.h"
34#include <Bitmap.h>
35
36#include "pdflib.h"
37#include "PrintUtils.h"
38#include "Cache.h"
39
40class Image;
41
42class ImageDescription : public CIDescription {
43public:
44	ImageDescription(PDF* pdf, BBitmap* bitmap, int mask);
45
46	CacheItem* NewItem(int id);
47
48	BBitmap* Bitmap() { return fBitmap; }
49	int Width() const { return fWidth; }
50	int Height() const { return fHeight; }
51	color_space ColorSpace() const { return fColorSpace; }
52	int Mask() const { return fMask; }
53
54private:
55	Image* Store(PDF* pdf, int id, BBitmap* bitmap, int mask);
56	bool StoreBitmap(const char* fileName, BBitmap* bitmap);
57	bool StorePNG(const char* fileName, BBitmap* bitmap);
58
59	PDF*        fPDF;
60	BBitmap*    fBitmap;
61	int         fWidth, fHeight;
62	color_space fColorSpace;
63	int         fMask;
64};
65
66class Image : public CacheItem {
67public:
68	Image(PDF* pdf, int imageID, const char* fileName, int width, int height, color_space colorSpace, int mask);
69	~Image();
70
71	int ImageID() const { return fImageID; };
72	const char* FileName() const  { return fFileName.String(); };
73	int Width() const { return fWidth; };
74	int Height() const { return fHeight; };
75	color_space ColorSpace() const { return fColorSpace; };
76	int Mask() const { return fMask; };
77	bool Equals(CIDescription* desc) const;
78	bool Equals(BBitmap* bitmap) const;
79
80private:
81	PDF*        fPDF;
82	int         fImageID;
83	BString     fFileName;
84	int         fWidth, fHeight;
85	color_space fColorSpace;
86	int         fMask;
87};
88
89
90
91#endif
92