Repository navigation
fix(raster): open one-bit scans in black and white #3623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
05375b1
68be14a
e07b1ab
c1ef39f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -249,6 +249,8 @@ pub struct Layout { | |
| pub lost: crate::loss::Notes, | ||
| /// The file says 0 is white, as [`super::Raster::white_is_zero`]. | ||
| pub white_is_zero: bool, | ||
| /// The bits a sample holds, when fewer than 8, as [`super::Raster::sample_bits`]. | ||
| pub sample_bits: Option<u8>, | ||
| /// Who holds the rights to the picture (its Copyright tag), as [`super::Raster::copyright`]. | ||
| pub copyright: Option<String>, | ||
| /// The file is in strips, not tiles (#2592): each level's tiles are its strips, as wide as the | ||
|
|
@@ -354,6 +356,8 @@ pub fn layout(bytes: &Sparse) -> Result<Parse> { | |
| } | ||
| } | ||
|
|
||
| /// Read the full image header without fetching its pixels, retaining the file metadata that | ||
| /// whole-file and windowed reads need to choose the same default appearance. | ||
| fn read_layout(r: Sparse) -> Result<Parse> { | ||
| // The same bytes, to tell a tag not read yet from one that is broken. | ||
| let seen = r.clone(); | ||
|
|
@@ -674,6 +678,7 @@ fn read_layout(r: Sparse) -> Result<Parse> { | |
| described, | ||
| lost, | ||
| white_is_zero, | ||
| sample_bits: u8::try_from(bits).ok().filter(|b| matches!(b, 1 | 2 | 4)), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bit depth here comes from the local Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A file whose bands' BitsPerSample differ, such as [1, 8], doesn't open on either route: the |
||
| copyright, | ||
| strips, | ||
| }))) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -867,6 +867,11 @@ pub struct Raster { | |
| /// The file says 0 is white (a TIFF's MinIsWhite): the values are as stored, and a stretch of | ||
| /// them is drawn the other way round. A raster with other values made from it starts without. | ||
| pub white_is_zero: bool, | ||
| /// The bits a sample holds in the file, when fewer than 8 (a TIFF's 1, 2 or 4). One-bit grey | ||
| /// defaults to black and white; 2- and 4-bit grey can still default to classes. Reprojecting, | ||
| /// clipping and imagery commands that keep its grey keep this too. Exporting to GeoTIFF | ||
| /// writes byte or float samples, not sub-byte samples, so that copy reopens without this mark. | ||
| pub sample_bits: Option<u8>, | ||
| transformer: Transformer, | ||
| extent: Extent, | ||
| } | ||
|
|
@@ -1057,6 +1062,7 @@ impl Raster { | |
| rounded_some: Vec::new(), | ||
| copyright: None, | ||
| white_is_zero: false, | ||
| sample_bits: None, | ||
| transformer, | ||
| extent: Extent::EMPTY, | ||
| }; | ||
|
|
@@ -1333,6 +1339,7 @@ impl Raster { | |
| r.step = if exact { self.step } else { 1 }; | ||
| (r.source, r.lost, r.copyright) = (self.source, self.lost, self.copyright); | ||
| r.white_is_zero = self.white_is_zero; | ||
| r.sample_bits = self.sample_bits; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This keeps Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 68be14a: warp/project and every imagery path that copies the source grey interpretation now retain |
||
| (r.rounded, r.rounded_some) = (self.rounded, self.rounded_some); | ||
| r | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6989,6 +6989,7 @@ pub(crate) fn read_window_raster(asked: &WindowAsked, stop: &std::sync::atomic:: | |
| rustgis_data::raster::Raster::new(&name, width, height, bands, transform, layout.crs, layout.nodata, color, layout.data_type) | ||
| .map_err(|e| named(e.to_string()))?; | ||
| r.white_is_zero = layout.white_is_zero; | ||
| r.sample_bits = layout.sample_bits; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The window read now copies Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The additional window-path tests are left for the release quality pass. |
||
| if rounded.iter().any(|n| *n > 0) { | ||
| r.rounded = rounded; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.