wheee
This commit is contained in:
commit
1d934000e6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
148
Cargo.lock
generated
Normal file
148
Cargo.lock
generated
Normal file
|
@ -0,0 +1,148 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "gethostname"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.143"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.26.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-wsapoll"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "x11_test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gif",
|
||||
"x11rb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11rb"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a"
|
||||
dependencies = [
|
||||
"gethostname",
|
||||
"nix",
|
||||
"winapi",
|
||||
"winapi-wsapoll",
|
||||
"x11rb-protocol",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11rb-protocol"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc"
|
||||
dependencies = [
|
||||
"nix",
|
||||
]
|
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "x11_test"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
gif = "*"
|
||||
x11rb = { version = "0.12.0", features = ["image"] }
|
69
src/.main.rs.rustfmt
Normal file
69
src/.main.rs.rustfmt
Normal file
|
@ -0,0 +1,69 @@
|
|||
#![allow(unreachable_code)]
|
||||
|
||||
use gif::{DecodeOptions, Frame};
|
||||
use std::fs::OpenOptions;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto::ConnectionExt;
|
||||
use x11rb::protocol::xproto::CreateGCAux;
|
||||
|
||||
fn main() {
|
||||
let (conn, screen_num) = x11rb::connect(None).unwrap();
|
||||
let screen = &conn.setup().roots[screen_num];
|
||||
let root = screen.root;
|
||||
let depth = screen.root_depth;
|
||||
|
||||
let pixmap = conn.generate_id().unwrap();
|
||||
conn.create_pixmap(depth, pixmap, root, 400, 400).unwrap();
|
||||
|
||||
let gc = conn.generate_id().unwrap();
|
||||
let gc_aux = CreateGCAux::new().foreground(screen.white_pixel);
|
||||
conn.create_gc(gc, root, &gc_aux).unwrap();
|
||||
|
||||
let arg = std::env::args().next().unwrap();
|
||||
let input = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("/home/gallant/Downloads/test3.gif")
|
||||
.unwrap();
|
||||
|
||||
input.sync_all().unwrap();
|
||||
|
||||
let mut de_options = DecodeOptions::new();
|
||||
de_options.set_color_output(gif::ColorOutput::RGBA);
|
||||
let mut decoder = de_options.read_info(input).unwrap();
|
||||
let mut v_frames: Vec<Frame> = Vec::new();
|
||||
while let Some(frame) = decoder.read_next_frame().unwrap() {
|
||||
v_frames.push(frame.clone());
|
||||
}
|
||||
let size = v_frames.len();
|
||||
|
||||
conn.flush().unwrap();
|
||||
|
||||
loop {
|
||||
let mut index = 0;
|
||||
if index == size {
|
||||
index = 0;
|
||||
}
|
||||
let buffer = &v_frames.get(index).unwrap().buffer;
|
||||
conn.put_image(
|
||||
x11rb::protocol::xproto::ImageFormat::Z_PIXMAP,
|
||||
root,
|
||||
gc,
|
||||
400,
|
||||
400,
|
||||
200,
|
||||
200,
|
||||
20,
|
||||
0,
|
||||
&buffer,
|
||||
)
|
||||
.unwrap();
|
||||
conn.copy_area(pixmap, root, gc, 0, 0, 0, 0, 400, 400)
|
||||
.unwrap();
|
||||
conn.flush().unwrap();
|
||||
index += 1;
|
||||
}
|
||||
|
||||
// unreachable but whatever
|
||||
conn.free_pixmap(pixmap).unwrap();
|
||||
conn.free_gc(gc).unwrap();
|
||||
}
|
75
src/main.rs
Normal file
75
src/main.rs
Normal file
|
@ -0,0 +1,75 @@
|
|||
#![allow(unreachable_code)]
|
||||
|
||||
use gif::{DecodeOptions, Frame};
|
||||
use std::fs::OpenOptions;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto::ConnectionExt;
|
||||
use x11rb::protocol::xproto::CreateGCAux;
|
||||
|
||||
use x11rb::image;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
fn main() {
|
||||
let (conn, screen_num) = x11rb::connect(None).unwrap(); //connects to xserver
|
||||
let screen = &conn.setup().roots[screen_num]; //gets the main screen
|
||||
let root = screen.root; //grabs the root ID of screen
|
||||
let depth = screen.root_depth; //grabs depth of root window
|
||||
|
||||
let pixmap = conn.generate_id().unwrap(); //generates an ID to use for pixel data presumably
|
||||
conn.create_pixmap(depth, pixmap, root, 1911, 999).unwrap(); //makes a space for pixel data on
|
||||
//root depth with pixmap ID at
|
||||
//400x400 space, need to make
|
||||
//larger
|
||||
|
||||
let gc = conn.generate_id().unwrap(); //generates another ID for Graphics Context
|
||||
let gc_aux = CreateGCAux::new().foreground(screen.white_pixel);// create aux for connecting the
|
||||
// context to thingy
|
||||
conn.create_gc(gc, root, &gc_aux).unwrap();
|
||||
|
||||
let _arg = std::env::args().next().unwrap();
|
||||
let input = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("test3.gif")
|
||||
.unwrap(); // Grabs image from arguement
|
||||
|
||||
|
||||
let mut de_options = DecodeOptions::new();
|
||||
de_options.set_color_output(gif::ColorOutput::RGBA);
|
||||
let mut decoder = de_options.read_info(input).unwrap(); //Decoder Shenanigans
|
||||
|
||||
let mut v_frames: VecDeque<Frame> = VecDeque::new();
|
||||
while let Some(frame) = decoder.read_next_frame().unwrap() {
|
||||
v_frames.push_back(frame.clone());
|
||||
}//Putting gif frames into a vector
|
||||
|
||||
conn.flush().unwrap();
|
||||
|
||||
loop {
|
||||
let popd = &v_frames.pop_front().unwrap();
|
||||
let buffer = &popd.buffer;
|
||||
|
||||
|
||||
let poten = conn.put_image(
|
||||
x11rb::protocol::xproto::ImageFormat::Z_PIXMAP,
|
||||
root,
|
||||
gc,
|
||||
1911,
|
||||
999,
|
||||
200,
|
||||
200,
|
||||
20,
|
||||
depth,
|
||||
&buffer,
|
||||
).unwrap();
|
||||
poten.check().unwrap();
|
||||
|
||||
conn.copy_area(pixmap, root, gc, 0, 0, 0, 0, 1911, 999).unwrap();
|
||||
v_frames.push_back(popd.clone());
|
||||
}
|
||||
conn.flush().unwrap();
|
||||
|
||||
// unreachable but whatever
|
||||
conn.free_pixmap(pixmap).unwrap();
|
||||
conn.free_gc(gc).unwrap();
|
||||
}
|
Loading…
Reference in a new issue