I'm using Delphitwain (delphitwain.sourceforge.net) to add scan functionality to my app. Scanning is working fine and I can save bmp and jpeg files. Now I need to:
After digging around, I found 2 tips:
http://www.delphipraxis.net/132787-farbstich-nach-bitmap-operation.html
http://synopse.info/fossil/wiki?name=GDI%2B
Here is my final code:
procedure TForm1.GoAcquireClick(Sender: TObject);
begin
Counter := 0;
Twain.SourceManagerLoaded := TRUE;
Twain.LoadSourceManager;
Twain.TransferMode := ttmMemory;
with Twain.Source[ 0 ] do
begin
Loaded := TRUE;
SetIXResolution(300);
SetIYResolution(300);
SetIBitDepth(1);
EnableSource(true, true);
while Enabled do Application.ProcessMessages;
end;
end;
procedure TForm1.TwainTwainAcquire(Sender: TObject; const Index: Integer;
Image: TBitmap; var Cancel: Boolean);
var
TiffHolder: TSynPicture;
begin
Inc( Counter );
Current := Counter;
ImageHolder.Picture.Assign( Image );
ImageHolder.Picture.Bitmap.Monochrome := true;
ImageHolder.Picture.Bitmap.Pixelformat := pf1Bit;
SynGDIPlus.SaveAs(ImageHolder.Picture, format('c:\temp\teste%d.tif',[ Counter ]), gptTIF );
end;
Result: the image still is 96dpi and were saved as BMP (even with TIF extension).
What am I missing?
Saving TIFF files is hard in Delphi. I don't know any free/open source modules that do this.
ImageEn works.
In the past I have used saving as bmp and converting to tiff with irfanview through createprocess with the commandline 'i_view32.exe c:\temp\scanned.bmp /bpp=1 /convert=c:\temp\scanned.tif'