Skip to content

Commit

Permalink
Added nil check for activeFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
DelphiWorlds committed Dec 7, 2024
1 parent 66a2798 commit 259035b
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Features/Camera/DW.Camera.iOS.pas
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,15 @@ procedure TPlatformCamera.UpdateExposureMode;
LISO: Single;
begin
LDevice := TAVCaptureDeviceEx.Wrap(NSObjectToID(FDevice));
LFormat := TAVCaptureDeviceFormatEx.Wrap(NSObjectToID(FDevice.activeFormat));
if Exposure > -1 then
LISO := LFormat.minISO + (Exposure * (LFormat.maxISO - LFormat.minISO))
else
LISO := FISODefault;
LDevice.setExposureModeCustomWithDuration(LDevice.exposureDuration, LISO, nil);
if LDevice.activeFormat <> nil then
begin
LFormat := TAVCaptureDeviceFormatEx.Wrap(NSObjectToID(LDevice.activeFormat));
if Exposure > -1 then
LISO := LFormat.minISO + (Exposure * (LFormat.maxISO - LFormat.minISO))
else
LISO := FISODefault;
LDevice.setExposureModeCustomWithDuration(LDevice.exposureDuration, LISO, nil);
end;
end;

procedure TPlatformCamera.UpdateExposureValue;
Expand All @@ -506,10 +509,13 @@ procedure TPlatformCamera.UpdateExposureValue;
LFormat: AVCaptureDeviceFormatEx;
begin
LDevice := TAVCaptureDeviceEx.Wrap(NSObjectToID(FDevice));
LFormat := TAVCaptureDeviceFormatEx.Wrap(NSObjectToID(FDevice.activeFormat));
if FISODefault = -1 then
FISODefault := LDevice.ISO;
InternalSetExposure((FISODefault - LFormat.minISO) / (LFormat.maxISO - LFormat.minISO));
if LDevice.activeFormat <> nil then
begin
LFormat := TAVCaptureDeviceFormatEx.Wrap(NSObjectToID(LDevice.activeFormat));
if FISODefault = -1 then
FISODefault := LDevice.ISO;
InternalSetExposure((FISODefault - LFormat.minISO) / (LFormat.maxISO - LFormat.minISO));
end;
end;

procedure TPlatformCamera.UpdateFlashMode;
Expand Down

0 comments on commit 259035b

Please sign in to comment.