| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#, SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#}; |
| 2 | |
| 3 | use craterust-analyzer cargo imagesize 0.13.0 crate/::{utilrust-analyzer cargo imagesize 0.13.0 util/::*, ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#, ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#}; |
| 4 | |
| 5 | pub fn sizerust-analyzer cargo imagesize 0.13.0 formats/tga/size().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>(reader: &mut R) -> ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#<ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#> { |
| 6 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(12))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 7 | |
| 8 | let width = read_u16rust-analyzer cargo imagesize 0.13.0 util/read_u16().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as usize; |
| 9 | let height = read_u16rust-analyzer cargo imagesize 0.13.0 util/read_u16().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as usize; |
| 10 | |
| 11 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize# { widthrust-analyzer cargo imagesize 0.13.0 ImageSize#width., heightrust-analyzer cargo imagesize 0.13.0 ImageSize#height. }) |
| 12 | } |
| 13 | |
| 14 | pub fn matchesrust-analyzer cargo imagesize 0.13.0 formats/tga/matches().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>(header: &[u8], reader: &mut R) -> bool { |
| 15 | // Do a naive check first to filter out any obviously non-TGA files |
| 16 | let colormap_type = header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 17 | let image_type = header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 18 | |
| 19 | // Check the image type (byte 2) to be one of the uncompressed or RLE compressed types |
| 20 | // Note: I've seen mention of types 0, 32, and 33 but have no example files so have omitted them. |
| 21 | if image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().1 |
| 22 | && image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().2 |
| 23 | && image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().3 |
| 24 | && image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().9 |
| 25 | && image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().10 |
| 26 | && image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().11 |
| 27 | { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | // Check that the colormap type (byte 1) is either 0 (no colormap) or 1 (colormap present) |
| 32 | // Technically 2-127 is reserved and 128-255 are usable by devs, but for simplicity we ignore them |
| 33 | if colormap_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().2 { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | is_tgarust-analyzer cargo imagesize 0.13.0 formats/tga/is_tga().(reader, image_type, colormap_type).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(false) |
| 38 | } |
| 39 | |
| 40 | fn is_tgarust-analyzer cargo imagesize 0.13.0 formats/tga/is_tga().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>( |
| 41 | reader: &mut R, |
| 42 | image_type: u8, |
| 43 | colormap_type: u8, |
| 44 | ) -> ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#<bool> { |
| 45 | // Attempt to go to footer section. This also doubles as a size check since |
| 46 | // if there aren't 18 bytes available it will return an error. |
| 47 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#End#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().18))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 48 | |
| 49 | // Look for Version 2 TGA footer signature as it's the only concrete data to verify it's a TGA |
| 50 | let mut signature = [0; 18]; |
| 51 | reader.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut signature)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 52 | |
| 53 | // If signature is found then we should be confident it's a TGA |
| 54 | // |
| 55 | // We do not reset the seek here because size methods should |
| 56 | // be seeking themselves as a first step anyway. |
| 57 | if &signature rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().b"TRUEVISION-XFILE.\0" { |
| 58 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true); |
| 59 | } |
| 60 | |
| 61 | // Now we're into heuristic territory. |
| 62 | // With no footer I don't believe there is a 100% way to verify whether given bytes |
| 63 | // are a TGA or not. To get around this we add a few corroborating byte checks and |
| 64 | // if they make up a valid TGA configuration we assume that it's a TGA. |
| 65 | |
| 66 | // If image type is color mapped, then color map type must be set to 1 |
| 67 | if (image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().1 || image_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().9) && colormap_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().1 { |
| 68 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 69 | } |
| 70 | |
| 71 | // Start reading the header information |
| 72 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(3))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 73 | |
| 74 | let colormap_offset = read_u32rust-analyzer cargo imagesize 0.13.0 util/read_u32().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 75 | let colormap_size = read_u8rust-analyzer cargo imagesize 0.13.0 util/read_u8().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 76 | |
| 77 | // If there is no color map then assume that origin, length, and entry size must be 0 |
| 78 | if colormap_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 { |
| 79 | if colormap_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0 { |
| 80 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 81 | } |
| 82 | |
| 83 | if colormap_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 { |
| 84 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // Assume color map sizes must be a multiple of 8 |
| 89 | if colormap_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().1 |
| 90 | && (colormap_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 |
| 91 | && colormap_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().8 |
| 92 | && colormap_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().16 |
| 93 | && colormap_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().24 |
| 94 | && colormap_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().32) |
| 95 | { |
| 96 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 97 | } |
| 98 | |
| 99 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(16))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 100 | let pixel_size = read_u8rust-analyzer cargo imagesize 0.13.0 util/read_u8().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 101 | let descriptor = read_u8rust-analyzer cargo imagesize 0.13.0 util/read_u8().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 102 | let alpha_bits = descriptor rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().0x0F; |
| 103 | |
| 104 | // Reserved bit, must be set to 0 |
| 105 | if descriptor rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().0x10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 { |
| 106 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 107 | } |
| 108 | |
| 109 | // Assume pixel size must be a multiple of 8 |
| 110 | if pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().8 && pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().16 && pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().24 && pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().32 { |
| 111 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 112 | } |
| 113 | |
| 114 | // Verify that the alpha bits value makes sense given pixel size |
| 115 | // |
| 116 | // 8 and 24 bits have no alpha |
| 117 | if (pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().8 || pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().24) && alpha_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 { |
| 118 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 119 | } |
| 120 | |
| 121 | // 16 bits can either have 0 or 1 bits of alpha |
| 122 | if pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().16 && alpha_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().2 { |
| 123 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 124 | } |
| 125 | |
| 126 | // 32 bits must have 8 bits of alpha, although I've seen one with 0? |
| 127 | if pixel_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().32 && (alpha_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().8 && alpha_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0) { |
| 128 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 129 | } |
| 130 | |
| 131 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true) |
| 132 | } |