gSlice := 0; {force a new image to be displayed - so gSlice should be different from displayimage requested slice}
//lStartTime := GetTickCount;
//showmessage('abba'+inttostr(red_table_size));
// Showmessage('MRIcro can not convert run-length compressed DICOM images. You can view this image with ezDICOM.'+inttostr(gDicomData.CompressOffset));
if (not gDicomData.GenesisCpt) and (gDicomData.CompressSz=0) and (not gDicomData.RunLengthEncoding)and ((lImageStart + (lAllocSliceSz*gDICOMdata.SamplesPerPixel)) > (FileSize(infp))) then begin
showmessage('This file does not have enough data for the image size:'+lFilename+kCR+'Image start: '+inttostr(lImageStart)+kCR+'Image size: '+inttostr(lAllocSliceSz*gDICOMdata.SamplesPerPixel));
closefile(infp);
FileMode := 2; //read/write
exit;
end;
Seek(infp, lImageStart);
if (gDICOMdata.Allocbits_per_pixel = 8) and(gDICOMdata.SamplesPerPixel = 3) then begin
if gBuff24Sz <>(lAllocSliceSz*gDICOMdata.SamplesPerPixel) then begin
if (gCustomPalette>0) or ((red_table_size > 0) and (red_table_size <= 256) and (red_table_size=green_table_size) and (red_table_size=blue_table_size)) then begin