pub fn add_entry(&mut self, direct_load: bool, r: u8, g: u8, b: u8) -> Result<usize, Error> {
		if self.entries.len() >= 256 {
			return Err(ErrorKind::PaletteFull.into());
		}
		if !direct_load {
			if let Some(i) = self.index_of_rgb(r, g, b) {
				return Ok(i);
			}
		}
		let entry = VeraPaletteEntry {
			r: r >> 4,
			g: g >> 4,
			b: b >> 4,
		};
		self.entries.push(entry);
		Ok(self.entries.len().saturating_sub(1))
	}
/// Adds an entry to the palette, failing if there's no room left
/// Only upper 4 bits are used.
/// Returns index if the color already exists
/// Returns the index
Adds an entry to the palette, failing if there's no room left
Only upper 4 bits are used.
Returns index if the color already exists
Returns the index
Adds an entry to the palette failing if there ' s no room left Only upper 4 bits are used . Returns index if the color already exists Returns the index
pub fn add_entry(&mut self, direct_load: bool, r: u8, g: u8, b: u8) -> Result<usize, Error> {
		if self.entries.len() >= 256 {
			return Err(ErrorKind::PaletteFull.into());
		}
		if !direct_load {
			if let Some(i) = self.index_of_rgb(r, g, b) {
				return Ok(i);
			}
		}
		let entry = VeraPaletteEntry {
			r: r >> 4,
			g: g >> 4,
			b: b >> 4,
		};
		self.entries.push(entry);
		Ok(self.entries.len().saturating_sub(1))
	}
pub fn add_entry ( & mut self , direct_load : bool , r : u8 , g : u8 , b : u8 ) -> Result < usize , Error > { if self . entries . len ( ) >= 256 { return Err ( ErrorKind :: PaletteFull . into ( ) ) ; } if ! direct_load { if let Some ( i ) = self . index_of_rgb ( r , g , b ) { return Ok ( i ) ; } } let entry = VeraPaletteEntry { r : r >> 4 , g : g >> 4 , b : b >> 4 , } ; self . entries . push ( entry ) ; Ok ( self . entries . len ( ) . saturating_sub ( 1 ) ) }
Adds an entry to the palette, failing if there's no room left
Only upper 4 bits are used.
Adds an entry to the palette failing if there ' s no room left Only upper 4 bits are used .
&mut self
direct_load
bool
r
u8
g
u8
b
u8