I don't think it has anything to do with color vs. B&W. I tried to attach two photos, one that worked and one that didn't. Both were color, and typical of photos my customers might try to load. They were too big to attach. I'll send you a DropBox link for the two files. The smaller one worked, but the larger one did not. I think it might have something to do with file size. I've included my code.
procedure TfrmMain.LoadSelectedDocument;
Var
FilNme,
FileExt: string;
Const
OneK = 1024.0;
OneM = 1048576.0;
begin
{$IFDEF UseCodeSite}
CodeSite.TraceMethod('qImageListAfterScroll');
{$ENDIF}
tmrScrollPause.Enabled := False;
showloadingform; // a splash screen that is hidden once the file is loaded.
Screen.Cursor := crHourGlass;
try
try
try
If not isNewImage then
begin
If FileExists(gsDocManPath + qImageList.FieldByName('ImageName').AsString) then
begin
FilNme := Trim(gsDocManPath + qImageList.FieldByName('ImageName').AsString);
(*** modified by David Cornelius to load multiple images and PDFs ***)
FileExt :=
Trim(UpperCase(ExtractFileExt(qImageList.FieldByName('ImageName').AsString)));
rzStatusPane2.Caption := 'Size: ' + ConvertBytes(GetImageFileSize(FilNme));
{===============================================================================
===== Actually get files ======
================================================================================}
if FileExt = '.TIF' then
begin
// if it's a .TIF file, we know it's capable of multiple images
ClearAllDocs;
iemvPageThumbs.StoreType := ietNormal;
ViewTIF;
end
else
if (FileExt = '.PNG') or (FileExt = '.JPG') or (FileExt = '.BMP') then
begin
iemvPageThumbs.StoreType := ietNormal;
ClearAllDocs;
ViewPNG;
end
else
if (FileExt = '.PDF') then
begin
ClearAllDocs;
ViewPDF;
end
else if (FileExt = '.DOCX') or (FileExt = '.DOC') then
begin
NewFileName := qImageList.FieldByName('ImageName').AsString;
ClearAllDocs;
ViewWordDoc;
end;
end
else
begin
{JPG or PNG handler.}
ClearAllDocs;
gbView.Caption := 'Photo/Image View:';
DisablePdfViewer;
ImageEnView1.Clear;
// "if" added by David Cornelius, May, 2004 to prevent this message when
// the last image is deleted
// the following statement previously stated > 0 rather than = 0
if Length(qImageList.FieldByName('ImageName').AsString) = 0 then
MessageBox(Application.Handle,PChar('No documents found.'),
'Information', MB_OK);
end;
end;
Application.ProcessMessages;
isNewImage := False;
CurrentFileName := qImageList.FieldByName('ImageName').AsString;
qImageList.EnableControls;
ShowLink; {Account, member, or policy}
RzStatusPane3.Caption := 'File: ' +qImageList. FieldByName('ImageName').AsString;
// ProgressBar1.Percent := 0;
Application.ProcessMessages;
finally
cxGrd1.Refresh;
Case LastZoomSelection of
lzsCustom : ImageEnView1.Zoom := ZoomFactor;
lzsBestFit: ImageEnView1.Fit;
lzsWidth: mnuFillWindowWidth1.Click;
lzsActualSize: mnu100Percent.Click;
End;
// Screen.Cursor := crDefault;
end;
except
on E : Exception do
begin
{I haven't seen this message since Adobe Acrobat DC. }
if pos('ole',LowerCase(E.Message)) <> 0 then
MessageBox(Application.Handle,
pChar('Document can''t be displayed. Please make sure you have installed '+
'the latest version of Adobe Acrobat Viewer. Yours may be out-of-date.'),
pChar('Document Error'), MB_OK + MB_ICONERROR);
end;
end;
finally
Screen.Cursor := crDefault;
hideloadingform ;
end;
end;
procedure TfrmMain.ViewTIF;
begin
{$IFDEF UseCodeSite}
CodeSiteEx.TraceMethod(self, 'ViewTIF');
{$ENDIF}
try
Screen.Cursor := crHourglass;
// Disable OleContainer. It's not needed by TIF files.
if (OleContainer1.State = osRunning) then
begin
try
OleContainer1.DestroyObject;
Except
MessageBox(Application.Handle, PChar('Error closing Word.'), PChar('FYI'), MB_OK + MB_ICONINFORMATION);
end;
end;
// change menu
mnuitmCombinePages.Caption := 'Add/Arrange &Pages';
// Make old image invisible;
ImageEnView1.Blank;
// disable PDF viewing
DisablePdfViewer; //hides the AcroPDF.DLL window.
// clear any previous thumbnails hanging around
iemvPageThumbs.Clear;
// load the .TIF file into the thumbnails to select different frames
iemvPageThumbs.MIO.LoadFromFileTIFF(Trim(gsDocManPath + qImageList.FieldByName('ImageName').AsString));
Application.ProcessMessages;
// // change menu
// mnuitmCombinePages.Caption := 'Add/Arrange &Pages';
// highlight first thumbnail
if iemvPageThumbs.ImageCount > 0 then iemvPageThumbs.SelectedImage := 0;
Application.ProcessMessages;
ImageEnView1.FitToWidth;
// show the thumbnail panel
iemvPageThumbs.Visible := True;
iemvPageThumbsImageSelect(nil,0);
iemvPageThumbs.Invalidate ;
EnableDocMenuItems; // enables or disables button and menu items based on document type (extension).
gbView.Caption := 'Document View:';
{This grid displayes all saved documents, and allows the user to select one to view.}
cxgrd1.Invalidate(True);
finally
Screen.Cursor := crDefault;
end;
end;