var
AValue:
string
;
APicture: TPicture;
sExt:
string
;
function
FileExtIsGraphicFileType(
const
aFileName:
string
):
boolean
;
var
lExt:
string
;
begin
lExt :=
'*'
+ ExtractFileExt(aFileName);
result := Pos( AnsiLowerCase(lExt), GraphicFilter(TGraphic) ) >
0
;
end
;
begin
AValue :=
''
;
if
FileExists(aFileName)
and
FileExtIsGraphicFileType(aFileName)
then
begin
APicture := TPicture
.
Create;
try
APicture
.
LoadFromFile(AFileName);
SavePicture(APicture, AValue);
finally
FreeAndNil(APicture);
end
;
end
;
sExt := ExtractFileExt(aFileName);
if
(sExt =
'.jpg'
)
then
ADataController
.
Values[ARecordIndex, APictureJPGColumnIndex] := AValue
else
if
(sExt =
'.bmp'
)
then
ADataController
.
Values[ARecordIndex, APictureBMPColumnIndex] := AValue
else
if
(sExt =
'.png'
)
then
ADataController
.
Values[ARecordIndex, APicturePNGColumnIndex] := AValue;
end
;