update for the sake of clarity
This commit is contained in:
parent
1d934000e6
commit
1dce58babe
BIN
output.gif
Normal file
BIN
output.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 MiB |
71
src/main.rs
71
src/main.rs
|
@ -6,7 +6,7 @@ use x11rb::connection::Connection;
|
|||
use x11rb::protocol::xproto::ConnectionExt;
|
||||
use x11rb::protocol::xproto::CreateGCAux;
|
||||
|
||||
use x11rb::image;
|
||||
use std::time;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
|
@ -17,55 +17,58 @@ fn main() {
|
|||
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
|
||||
conn.create_pixmap(depth, pixmap, root, 1920, 1080).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
|
||||
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 input = OpenOptions::new().read(true).open("output.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
|
||||
|
||||
v_frames.push_back(frame.clone());
|
||||
} //Putting gif frames into a vector
|
||||
|
||||
conn.flush().unwrap();
|
||||
|
||||
let mut instant = time::Instant::now();
|
||||
loop {
|
||||
let popd = &v_frames.pop_front().unwrap();
|
||||
let buffer = &popd.buffer;
|
||||
|
||||
if instant.elapsed().as_millis() >= 0 {
|
||||
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();
|
||||
let put = conn
|
||||
.put_image(
|
||||
x11rb::protocol::xproto::ImageFormat::Z_PIXMAP,
|
||||
root,
|
||||
gc,
|
||||
1920,
|
||||
1080,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
depth,
|
||||
&buffer,
|
||||
)
|
||||
.unwrap();
|
||||
put.check().unwrap();
|
||||
|
||||
conn.copy_area(pixmap, root, gc, 0, 0, 0, 0, 1911, 999).unwrap();
|
||||
v_frames.push_back(popd.clone());
|
||||
let copy = conn.copy_area(pixmap, root, gc, 0, 0, 0, 0, 1920, 1080)
|
||||
.unwrap();
|
||||
copy.check().unwrap();
|
||||
|
||||
v_frames.push_back(popd.clone());
|
||||
instant = time::Instant::now();
|
||||
}
|
||||
}
|
||||
conn.flush().unwrap();
|
||||
|
||||
|
|
Loading…
Reference in a new issue