yea
This commit is contained in:
parent
4484143a0f
commit
2356cb5406
1
output.txt
Normal file
1
output.txt
Normal file
File diff suppressed because one or more lines are too long
1
output_RGBA.txt
Normal file
1
output_RGBA.txt
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,69 +0,0 @@
|
|||
#![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();
|
||||
}
|
48
src/main.rs
48
src/main.rs
|
@ -9,35 +9,40 @@ use x11rb::protocol::xproto::CreateGCAux;
|
|||
use std::collections::VecDeque;
|
||||
|
||||
fn main() {
|
||||
let _arg = std::env::args().next().unwrap();
|
||||
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();
|
||||
|
||||
let height = decoder.height();
|
||||
let width = decoder.width();
|
||||
|
||||
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, 1920, 1080).unwrap(); //makes a space for pixel data on
|
||||
//root depth with pixmap ID at
|
||||
//400x400 space, need to make
|
||||
//larger
|
||||
let pixmap = conn.generate_id().unwrap(); //generates an ID to use for pixel data presumably
|
||||
conn.create_pixmap(depth, pixmap, root, width, height)
|
||||
.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("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
|
||||
//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();
|
||||
println!("{:?}", v_frames.get(0));
|
||||
loop {
|
||||
let popd = &v_frames.pop_front().unwrap();
|
||||
|
||||
|
@ -46,8 +51,8 @@ fn main() {
|
|||
x11rb::protocol::xproto::ImageFormat::Z_PIXMAP,
|
||||
root,
|
||||
gc,
|
||||
1920,
|
||||
1080,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -55,19 +60,18 @@ fn main() {
|
|||
&popd.buffer,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// let copy = conn
|
||||
// .copy_area(pixmap, root, gc, 0, 0, 0, 0, 1920, 1080)
|
||||
// .unwrap();
|
||||
|
||||
let copy = conn
|
||||
.copy_area(root, pixmap, gc, 0, 0, 0, 0, width, height)
|
||||
.unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
v_frames.push_back(popd.clone());
|
||||
|
||||
put.check().unwrap();
|
||||
//copy.check().unwrap();
|
||||
copy.check().unwrap();
|
||||
}
|
||||
conn.flush().unwrap();
|
||||
|
||||
// unreachable but whatever
|
||||
//conn.free_pixmap(pixmap).unwrap();
|
||||
conn.free_pixmap(pixmap).unwrap();
|
||||
conn.free_gc(gc).unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue