#1 Re: GDI+ » Draw image and save as tiff » 2012-09-16 12:01:46

Thanks AB,

I ploughed through the mORMot documentation, and found -

'Save the picture into any GIF/PNG/JPG/TIFF format - CompressionQuality is used for gptJPG format saving and is expected to be from 0 to 100; for gptTIF format, use ord(TGDIPPEncoderValue) to define the parameter; by default, will use ord(evCompressionLZW) to save the TIFF picture with LZW - for gptTIF, only valid values are ord(evCompressionLZW), ord(evCompressionCCITT3), ord(evCompressionCCITT4), ord(evCompressionRle) and ord(evCompressionNone) function ToBitmap: TBitmap;'

So I tried -

SynGDIPlus.SaveAs(Bmp, 'c:\test.tif', gptTIF, ord(evCompressionLZW), 0, 300);

which now works and so does ord(evCompressionNone) and would presumably with the other compression settings.

I also noticed the line - 'Sub class to handle .TIF file extension - GDI + seems not able to load all Tiff file formats' which maybe a warning, but there is also -
GDI+ available filling modes TGDIPPEncoderValue = ( evColorTypeCMYK, evColorTypeYCCK, evCompressionLZW, evCompressionCCITT3, evCompressionCCITT4, evCompressionRle, evCompressionNone, evScanMethodInterlaced, evScanMethodNonInterlaced, evVersionGif87, evVersionGif89, evRenderProgressive, evRenderNonProgressive, evTransformRotate90, evTransformRotate180, evTransformRotate270, evTransformFlipHorizontal, evTransformFlipVertical, evMultiFrame, evLastFrame, evFlush, evFrameDimensionTime, evFrameDimensionResolution, evFrameDimensionPage );

I don't understand how I could try this. What would be the Delphi code be that implemented Color, Compression and Dpi? It appears only three parameters are allowed. I tried -

SynGDIPlus.SaveAs(Bmp, 'c:\test.tif', gptTIF, ord(evCompressionLZW), ord(evColorTypeCMYK), 300);
and then
SynGDIPlus.SaveAs(Bmp, 'c:\test.tif', gptTIF, ord(evColorTypeCMYK), 0, 300);

both of which ran OK, but don't do anything to the colour, which remains stubbonly at RGB. Interestingly, there's no evColorTypeRGB mentioned.

Any help appreciated.

#2 Re: GDI+ » Draw image and save as tiff » 2012-09-15 22:16:31

I downloaded SynGdiPlus.zip on 12/9/12 via http://synopse.info/fossil/wiki?name=Downloads. The included SynGdiPlus.pas is dated 17/9/11. As it doesn't run 'stand alone', I downloaded SynPdf.zip to get SQLPages.zip, etc., dated 25/9/11. I notice that mORMOT.7z has newer versions via the same downloads page. I've updated and am now bowled over at being able to convince Photoshop that it really is a 300dpi Tif!

BTW. What are the minimum code requirements for SynGdiPlus? I may well need mORMOT one day, but for now I need SynGdi+. Is including just SQLPages enough?)

The antialiasing, resizing and file format conversion work a treat, by the way. All I need now is LZ compression and  conversion to CYMK, but maybe that's asking too much? Could I, if this is the line, ask for amendments to -

SynGDIPlus.SaveAs(Bmp, 'c:\test.tif', gptTIF, 80, 0, 300);

Many thanks for your great work.

#3 Re: GDI+ » Draw image and save as tiff » 2012-09-14 23:35:54

I've been trying to automate saving to 300dpi Tif's for ages and noticed AB's code snippet of 02/08/12 -

Bmp := Gdip.DrawAntiAliased(MF);
Image1.Picture.Assign(Bmp);
SynGDIPlus.SaveAs(Bmp, 'c:\test.tif', gptTIF, 80, 0, 200); // force 200 DPI
Bmp.Free;

Just that I get 'Too many actual parameters'. Knocking off the 200 creates a Tif OK, but the very parameter I need seems to be unavailable.

Any ideas gratefully etc.

Board footer

Powered by FluxBB