function TfmViewPIx.ReadScannedDocument(): Boolean; var TiffWidth, TiffLength: LongInt; TiffCompress: string; NumberOfPages, Tiffres: Smallint; sTempDir: String; begin Result := False; sTempDir := Temp(); // SAN if FileExists(sTempDir + 'multipage.tif') then begin ImageView1.Clear; Sysutils.DeleteFile(sTempDir + 'multipage.tif'); Sysutils.DeleteFile(sTempDir + 'temp_frame.bmp'); end; { Load the scan from the DB into a stream } MemoryStream.Clear; MemoryStream.Size := 0; BLOB_OpenBlob(MemoryStream, quQueryINBLOBKEY.AsString); if (MemoryStream = nil) or (MemoryStream.Size = 0) then //42732 Exit; { Check that we have a valid tiff file } TiffWidth := 0; TiffLength := 0; TiffCompress := ''; NumberOfPages := 0; Tiffres := 0; GetBlobTiffInfo(MemoryStream.Memory, MemoryStream.Size, 0, TiffWidth, TiffLength, TiffCompress, NumberOfPages, Tiffres); //XXXTODO should we be checking the return code? MemoryStream.SaveToFile(sTempDir + 'multipage.tif'); { If there is nothing in the stream to load then dont load anything } begin BlobIsTIFF := True; { Read in the first page } //DpiX and DpiY are not the same, so do the autadjustdpi before loading ImageView1.MIO.AutoAdjustDPI := True;//ALM:#137386 ImageView1.MIO.LoadFromFile(sTempDir + 'multipage.tif'); ImageView1.VisibleFrame := 0; ImageView1.EnableResamplingOnMinor := false; Image1.Assign(ImageView1.GetBitmap(ImageView1.VisibleFrame)); ImageView1.ReleaseBitmap(ImageView1.VisibleFrame); Image1.Zoom := (((Image1.Width - 25)/Image1.IO.Bitmap.Width)*100); end; UpdatePageDetails(ImageView1.VisibleFrame + 1, ImageView1.ImageCount, Image1.Zoom); bAnnotationChanged := False; bRotated := False; { Ensure that the scanned document controls are updated } UpdateScanControls(); Result := True; end; procedure TfmViewPIx.aiScanNextPageExecute(Sender: TObject); begin inherited; if ImageView1.VisibleFrame < ImageView1.ImageCount then begin Image1.Clear; Image1.Bitmap.FreeImage; ImageView1.VisibleFrame := ImageView1.VisibleFrame + 1; Image1.Assign(ImageView1.GetBitmap(ImageView1.VisibleFrame)); ImageView1.ReleaseBitmap(ImageView1.VisibleFrame); FitImageToWidth; UpdateScanControls(); UpdatePageDetails(ImageView1.VisibleFrame + 1, ImageView1.ImageCount, Image1.Zoom); end; end;