Javier13, en el editor del foro hay un botón con el ícono de Delphi. Ese te ayuda a mostrar el código de la forma correcta.
Acá te dejo un ejemplo. La validación la hago antes de cargar la imagen.
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
function FileSize(const aFilename: String): Int64;
var
info: TWin32FileAttributeData;
begin
result := -1;
if not GetFileAttributesEx(PWideChar(aFileName), GetFileExInfoStandard, @info) then
Exit;
result := Int64(info.nFileSizeLow) or Int64(info.nFileSizeHigh shl 32);
end;
var
Dlg : TOpenDialog;
begin
Dlg := TOpenDialog.Create(Self);
try
Dlg.Title := 'Cargar imágen';
Dlg.Filter := 'Archivos BMP|*.bmp';
if Dlg.Execute then
begin
if FileSize(Dlg.FileName) > 524288 then
begin
MessageBox(0, 'El tamaño del archivo debe ser menor a 512 Kb',
PChar(Self.Caption), MB_ICONSTOP or MB_OK);
Exit;
end;
Image1.Picture.Bitmap.LoadFromFile(Dlg.FileName);
end;
finally
FreeAndNil(Dlg)
end;
end;
La prueba es en Delphi XE4