Project

General

Profile

dt.patch

simplification of dt_image_print_exif - Mark Oteiza, 09/25/2016 05:56 PM

View differences:

src/common/image.c
272 272

  
273 273
void dt_image_print_exif(const dt_image_t *img, char *line, size_t line_len)
274 274
{
275
  if(img->exif_exposure >= 4.0f) // Use whole seconds (e.g., 5" for exposures >= 4s)
276
    snprintf(line, line_len, "%.0f″ f/%.1f %dmm iso %d", img->exif_exposure, img->exif_aperture,
277
             (int)img->exif_focal_length, (int)img->exif_iso);
278
  else if(img->exif_exposure < 0.35f) // Use fractions (e.g., 1/200 all the way up to 1/3)
275
  if(img->exif_exposure >= 1.0f)
276
    if(nearbyintf(img->exif_exposure) == img->exif_exposure)
277
      snprintf(line, line_len, "%.0f″ f/%.1f %dmm iso %d", img->exif_exposure, img->exif_aperture,
278
               (int)img->exif_focal_length, (int)img->exif_iso);
279
    else
280
      snprintf(line, line_len, "%.1f″ f/%.1f %dmm iso %d", img->exif_exposure, img->exif_aperture,
281
               (int)img->exif_focal_length, (int)img->exif_iso);
282
  else
279 283
    snprintf(line, line_len, "1/%.0f f/%.1f %dmm iso %d", 1.0 / img->exif_exposure, img->exif_aperture,
280 284
             (int)img->exif_focal_length, (int)img->exif_iso);
281
  else // Use seconds and tenths (e.g., 1"2 for 1.2s exposure)
282
  {
283
    // Round first so we don't end up showing 0"10 instead of 1"0
284
    float exposure = roundf(img->exif_exposure*10.0f)/10.0f;
285
    float integral = 0.0f;
286
    float fractional = modff(exposure, &integral) * 10.0f;
287
    snprintf(line, line_len, "%.0f″%.0f f/%.1f %dmm iso %d", integral, fractional, img->exif_aperture,
288
             (int)img->exif_focal_length, (int)img->exif_iso);
289
  }
290 285
}
291 286

  
292 287
void dt_image_set_location(const int32_t imgid, double lon, double lat)
Go to top