#include "CtrlCore.h"

#ifdef NEWIMAGE
#ifdef PLATFORM_X11

#include <plugin/bmp/bmp.h>

Image ReadClipboardImage()
{
	Image m = ReadClipboardFormat<Image>();
	if(!m.IsEmpty())
		return m;
	Image img = StreamRaster::LoadStringAny(ReadClipboard(XAtom("image/bmp")));
	if(!img.IsEmpty())
		return img;
	return StreamRaster::LoadStringAny(ReadClipboard(XAtom("image/png")));
}

bool WriteClipboardImage(const Image& img, bool clear)
{
	if(clear)
		ClearClipboard();
	WriteClipboardFormat(img, false);
	BMPEncoder bmp;
	WriteClipboard(XAtom("image/bmp"), bmp.SaveString(img), clear);
}

#endif
#endif
