Beispiel #1
0
void FI(saveImageFile)(const Bitmap& bitmap, Gosu::Writer writer,
                       const std::wstring& formatHint)
{
    std::string utf8FormatHint = wstringToUTF8(formatHint);
    FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(utf8FormatHint.c_str());
    FIBITMAP* fib = bitmapToFIB(bitmap, fif);

    FreeImageIO fio = { NULL, WriteProc, SeekProc, TellProc };
    FreeImage_SaveToHandle(fif, fib, &fio, &writer);
    FreeImage_Unload(fib);
    checkForFreeImageErrors();
}
Beispiel #2
0
BOOL DLL_CALLCONV
FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags) {
	if (stream) {
		FreeImageIO io;
		SetMemoryIO(&io);

		FIMEMORYHEADER *mem_header = (FIMEMORYHEADER*)(stream->data);

		if(mem_header->delete_me == TRUE) {
			return FreeImage_SaveToHandle(fif, dib, &io, (fi_handle)stream, flags);
		} else {
			// do not save in a user buffer
			FreeImage_OutputMessageProc(fif, "Memory buffer is read only");
		}
	}

	return FALSE;
}
Beispiel #3
0
bool ImageExporter::save(QIODevice *device)
{
	if (!d->bitmap)
		return false;
	
	if (d->format == FIF_UNKNOWN)
		return false;
	
	int flags = 0;
	
	if (d->format == FIF_JPEG)
		flags = d->quality;
	
	FreeImage_SetOutputMessage(outputMessage);
	
	FreeImageIO io;
	io.read_proc = 0;
	io.write_proc = writeToQIODevice;
	io.seek_proc = seekQIODevice;
	io.tell_proc = tellQIODevice;
	
	return FreeImage_SaveToHandle(d->format, d->bitmap, &io, device, flags);
}
Beispiel #4
0
BOOL fipImage::saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag) const {
	BOOL bSuccess = FALSE;

	if(fif != FIF_UNKNOWN ) {
		// Check that the dib can be saved in this format
		BOOL bCanSave;

		FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib);
		if(image_type == FIT_BITMAP) {
			// standard bitmap type
			WORD bpp = FreeImage_GetBPP(_dib);
			bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp));
		} else {
			// special bitmap type
			bCanSave = FreeImage_FIFSupportsExportType(fif, image_type);
		}

		if(bCanSave) {
			bSuccess = FreeImage_SaveToHandle(fif, _dib, io, handle, flag);
			return bSuccess;
		}
	}
	return bSuccess;
}