2 * Copyright 2006, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
9 #include "BitmapExporter.h"
12 #include <BitmapStream.h>
13 #include <TranslatorFormats.h>
14 #include <TranslatorRoster.h>
17 #include "IconRenderer.h"
20 BitmapExporter::BitmapExporter(uint32 size
)
22 fFormat(B_PNG_FORMAT
),
28 BitmapExporter::~BitmapExporter()
34 BitmapExporter::Export(const Icon
* icon
, BPositionIO
* stream
)
39 // render icon into bitmap with given size and transparent background
40 uint32 bitmapFlags
= 0;
43 bitmapFlags
|= B_BITMAP_NO_SERVER_LINK
;
46 BBitmap
bitmap(BRect(0, 0, fSize
- 1, fSize
- 1),
47 bitmapFlags
, B_RGBA32
);
49 status_t ret
= bitmap
.InitCheck();
53 IconRenderer
renderer(&bitmap
);
54 renderer
.SetIcon(icon
);
55 renderer
.SetScale(fSize
/ 64.0);
57 // renderer.Demultiply(&bitmap);
59 // save bitmap to translator
60 BTranslatorRoster
* roster
= BTranslatorRoster::Default();
64 BBitmapStream
bitmapStream(&bitmap
);
65 ret
= roster
->Translate(&bitmapStream
, NULL
, NULL
, stream
, fFormat
, 0);
68 bitmapStream
.DetachBitmap(&dummy
);
75 BitmapExporter::MIMEType()