Changeset View
Changeset View
Standalone View
Standalone View
kstars/fitsviewer/fitsdata.cpp
Show First 20 Lines • Show All 3294 Lines • ▼ Show 20 Line(s) | 3269 | { | |||
---|---|---|---|---|---|
3295 | { | 3295 | { | ||
3296 | KSNotification::error(i18n("Unsupported bayer pattern %1.", pattern), i18n("Debayer error")); | 3296 | KSNotification::error(i18n("Unsupported bayer pattern %1.", pattern), i18n("Debayer error")); | ||
3297 | return false; | 3297 | return false; | ||
3298 | } | 3298 | } | ||
3299 | 3299 | | |||
3300 | fits_read_key(fptr, TINT, "XBAYROFF", &debayerParams.offsetX, nullptr, &status); | 3300 | fits_read_key(fptr, TINT, "XBAYROFF", &debayerParams.offsetX, nullptr, &status); | ||
3301 | fits_read_key(fptr, TINT, "YBAYROFF", &debayerParams.offsetY, nullptr, &status); | 3301 | fits_read_key(fptr, TINT, "YBAYROFF", &debayerParams.offsetY, nullptr, &status); | ||
3302 | 3302 | | |||
3303 | if (debayerParams.offsetX == 1) | ||||
3304 | { | ||||
3305 | // This may leave odd values in the 0th column if the color filter is not there | ||||
3306 | // in the sensor, but otherwise should process the offset correctly. | ||||
3307 | // Only offsets of 0 or 1 are implemented in debayer_8bit() and debayer_16bit(). | ||||
3308 | switch (debayerParams.filter) | ||||
3309 | { | ||||
3310 | case DC1394_COLOR_FILTER_RGGB: | ||||
3311 | debayerParams.filter = DC1394_COLOR_FILTER_GRBG; | ||||
3312 | break; | ||||
3313 | case DC1394_COLOR_FILTER_GBRG: | ||||
3314 | debayerParams.filter = DC1394_COLOR_FILTER_BGGR; | ||||
3315 | break; | ||||
3316 | case DC1394_COLOR_FILTER_GRBG: | ||||
3317 | debayerParams.filter = DC1394_COLOR_FILTER_RGGB; | ||||
3318 | break; | ||||
3319 | case DC1394_COLOR_FILTER_BGGR: | ||||
3320 | debayerParams.filter = DC1394_COLOR_FILTER_GBRG; | ||||
3321 | break; | ||||
3322 | } | ||||
3323 | debayerParams.offsetX = 0; | ||||
3324 | } | ||||
3325 | if (debayerParams.offsetX != 0 || debayerParams.offsetY > 1 || debayerParams.offsetY < 0) | ||||
3326 | { | ||||
3327 | KSNotification::error(i18n("Unsupported bayer offsets %1 %2.", | ||||
3328 | debayerParams.offsetX, debayerParams.offsetY), i18n("Debayer error")); | ||||
3329 | return false; | ||||
3330 | } | ||||
3331 | | ||||
3303 | HasDebayer = true; | 3332 | HasDebayer = true; | ||
3304 | 3333 | | |||
3305 | return true; | 3334 | return true; | ||
3306 | } | 3335 | } | ||
3307 | 3336 | | |||
3308 | void FITSData::getBayerParams(BayerParams * param) | 3337 | void FITSData::getBayerParams(BayerParams * param) | ||
3309 | { | 3338 | { | ||
3310 | param->method = debayerParams.method; | 3339 | param->method = debayerParams.method; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 3384 | { | |||
3370 | int ds1394_height = stats.height; | 3399 | int ds1394_height = stats.height; | ||
3371 | auto dc1394_source = bayer_source_buffer; | 3400 | auto dc1394_source = bayer_source_buffer; | ||
3372 | 3401 | | |||
3373 | if (debayerParams.offsetY == 1) | 3402 | if (debayerParams.offsetY == 1) | ||
3374 | { | 3403 | { | ||
3375 | dc1394_source += stats.width; | 3404 | dc1394_source += stats.width; | ||
3376 | ds1394_height--; | 3405 | ds1394_height--; | ||
3377 | } | 3406 | } | ||
3378 | 3407 | // offsetX == 1 is handled in checkDebayer() and should be 0 here. | |||
3379 | if (debayerParams.offsetX == 1) | | |||
3380 | { | | |||
3381 | dc1394_source++; | | |||
3382 | } | | |||
3383 | 3408 | | |||
3384 | error_code = dc1394_bayer_decoding_8bit(dc1394_source, bayer_destination_buffer, stats.width, ds1394_height, debayerParams.filter, | 3409 | error_code = dc1394_bayer_decoding_8bit(dc1394_source, bayer_destination_buffer, stats.width, ds1394_height, debayerParams.filter, | ||
3385 | debayerParams.method); | 3410 | debayerParams.method); | ||
3386 | 3411 | | |||
3387 | if (error_code != DC1394_SUCCESS) | 3412 | if (error_code != DC1394_SUCCESS) | ||
3388 | { | 3413 | { | ||
3389 | KSNotification::error(i18n("Debayer failed (%1)", error_code), i18n("Debayer error")); | 3414 | KSNotification::error(i18n("Debayer failed (%1)", error_code), i18n("Debayer error")); | ||
3390 | m_Channels = 1; | 3415 | m_Channels = 1; | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 3457 | { | |||
3447 | int ds1394_height = stats.height; | 3472 | int ds1394_height = stats.height; | ||
3448 | auto dc1394_source = bayer_source_buffer; | 3473 | auto dc1394_source = bayer_source_buffer; | ||
3449 | 3474 | | |||
3450 | if (debayerParams.offsetY == 1) | 3475 | if (debayerParams.offsetY == 1) | ||
3451 | { | 3476 | { | ||
3452 | dc1394_source += stats.width; | 3477 | dc1394_source += stats.width; | ||
3453 | ds1394_height--; | 3478 | ds1394_height--; | ||
3454 | } | 3479 | } | ||
3455 | 3480 | // offsetX == 1 is handled in checkDebayer() and should be 0 here. | |||
3456 | if (debayerParams.offsetX == 1) | | |||
3457 | { | | |||
3458 | dc1394_source++; | | |||
3459 | } | | |||
3460 | 3481 | | |||
3461 | error_code = dc1394_bayer_decoding_16bit(dc1394_source, bayer_destination_buffer, stats.width, ds1394_height, debayerParams.filter, | 3482 | error_code = dc1394_bayer_decoding_16bit(dc1394_source, bayer_destination_buffer, stats.width, ds1394_height, debayerParams.filter, | ||
3462 | debayerParams.method, 16); | 3483 | debayerParams.method, 16); | ||
3463 | 3484 | | |||
3464 | if (error_code != DC1394_SUCCESS) | 3485 | if (error_code != DC1394_SUCCESS) | ||
3465 | { | 3486 | { | ||
3466 | KSNotification::error(i18n("Debayer failed (%1)", error_code), i18n("Debayer error")); | 3487 | KSNotification::error(i18n("Debayer failed (%1)", error_code), i18n("Debayer error")); | ||
3467 | m_Channels = 1; | 3488 | m_Channels = 1; | ||
▲ Show 20 Lines • Show All 897 Lines • Show Last 20 Lines |