mirror of
https://github.com/bend-n/fimg.git
synced 2024-12-22 10:28:21 -06:00
This commit is contained in:
parent
b1e75f0548
commit
3a1b6a3435
|
@ -44,12 +44,13 @@ impl<T: AsRef<[u8]>, const N: usize> Sixel<T, N> {
|
||||||
let q = {
|
let q = {
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
// SAFETY: is stdout a tty
|
// SAFETY: is stdout a tty
|
||||||
(unsafe { libc::isatty(0) } == 1)
|
(unsafe { libc::isatty(1) } == 1)
|
||||||
};
|
};
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
let q = true;
|
let q = true;
|
||||||
let colors = q
|
let colors = q
|
||||||
.then_some(super::query("[?1;1;0S").and_then(|x| {
|
.then(|| {
|
||||||
|
super::query("[?1;1;0S").and_then(|x| {
|
||||||
// [?1;0;65536S
|
// [?1;0;65536S
|
||||||
if let [b'?', b'1', b';', b'0', b';', n @ ..] = x.as_bytes() {
|
if let [b'?', b'1', b';', b'0', b';', n @ ..] = x.as_bytes() {
|
||||||
Some(
|
Some(
|
||||||
|
@ -65,7 +66,8 @@ impl<T: AsRef<[u8]>, const N: usize> Sixel<T, N> {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
.unwrap_or(255);
|
.unwrap_or(255);
|
||||||
to.write_str("Pq")?;
|
to.write_str("Pq")?;
|
||||||
|
@ -104,13 +106,10 @@ impl<T: AsRef<[u8]>, const N: usize> Sixel<T, N> {
|
||||||
write!(to, "#{i};2;{r};{g};{b}")?;
|
write!(to, "#{i};2;{r};{g};{b}")?;
|
||||||
}
|
}
|
||||||
for sixel_row in pixels.chunks_exact(self.width() as usize * 6).map(|x| {
|
for sixel_row in pixels.chunks_exact(self.width() as usize * 6).map(|x| {
|
||||||
let mut x = x
|
x.iter()
|
||||||
.iter()
|
|
||||||
.zip(0u32..)
|
.zip(0u32..)
|
||||||
.map(|(&p, j)| (p, (j % self.width(), j / self.width())))
|
.map(|(&p, j)| (p, (j % self.width(), j / self.width())))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>()
|
||||||
x.sort_unstable();
|
|
||||||
x
|
|
||||||
}) {
|
}) {
|
||||||
// extracted
|
// extracted
|
||||||
for samples in Grouped(&sixel_row, |r| r.0) {
|
for samples in Grouped(&sixel_row, |r| r.0) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue