116234Smichaelm/*
216234Smichaelm * Copyright 2009, Haiku Inc. All Rights Reserved.
316234Smichaelm * Distributed under the terms of the MIT License.
416234Smichaelm */
516234Smichaelm#ifndef _BITMAP_STREAM_H
616234Smichaelm#define _BITMAP_STREAM_H
716234Smichaelm
816234Smichaelm
916234Smichaelm#include <ByteOrder.h>
1016234Smichaelm#include <DataIO.h>
1116234Smichaelm#include <TranslationDefs.h>
1216234Smichaelm#include <TranslatorFormats.h>
1316234Smichaelm
1416234Smichaelm
1516234Smichaelmclass BBitmap;
1616234Smichaelm
1716234Smichaelm
1816234Smichaelmclass BBitmapStream : public BPositionIO {
1916234Smichaelmpublic:
2016234Smichaelm								BBitmapStream(BBitmap* bitmap = NULL);
2116234Smichaelm	virtual						~BBitmapStream();
2216234Smichaelm
2317113Sihse	virtual	ssize_t				ReadAt(off_t offset, void* buffer, size_t size);
2416234Smichaelm	virtual	ssize_t				WriteAt(off_t offset, const void* buffer,
2516234Smichaelm									size_t size);
2616234Smichaelm	virtual	off_t				Seek(off_t position, uint32 seekMode);
2716234Smichaelm	virtual	off_t				Position() const;
2816234Smichaelm	virtual	off_t				Size() const;
2916234Smichaelm	virtual	status_t			SetSize(off_t size);
3016234Smichaelm
3116234Smichaelm			status_t			DetachBitmap(BBitmap** _bitmap);
3216234Smichaelm
3316234Smichaelmprotected:
3416234Smichaelm			void				SwapHeader(const TranslatorBitmap* source,
3516234Smichaelm									TranslatorBitmap* destination);
3616234Smichaelm
3716234Smichaelmprotected:
3816234Smichaelm			TranslatorBitmap	fHeader;
3916234Smichaelm			BBitmap*			fBitmap;
4016234Smichaelm			size_t				fPosition;
4116234Smichaelm			size_t				fSize;
4216234Smichaelm			bool				fDetached;
4316234Smichaelm
4416234Smichaelmprivate:
4516234Smichaelm	virtual	void _ReservedBitmapStream1();
4616234Smichaelm	virtual void _ReservedBitmapStream2();
4716234Smichaelm
4816234Smichaelmprivate:
4916234Smichaelm			TranslatorBitmap*	fBigEndianHeader;
5016234Smichaelm			long				_reserved[5];
5116234Smichaelm};
5216234Smichaelm
5316234Smichaelm
5416234Smichaelm#endif	// _BITMAP_STREAM_H
5516234Smichaelm