Giter VIP home page Giter VIP logo

gifor's Introduction

gifor: 项目介绍

1. 介绍

相关文章参见:

对于一些每帧只有一小部分有变化的GIF动图来说,Mathematica导出GIF图像时,每帧都使用了整幅图像,而不是仅发生变化的部分。对于这种情况,直接使用Mathematica导出的GIF图像文件占用空间会比较大。

而在GIF编码协议中,每帧可以是不大于整个图像尺寸的任意大小的图像,而且可以指定其位置,这就给解决上面的问题提供了一个有效的方法。

于是为了解决该问题,我看了几遍《GRAPHICS INTERCHANGE FORMAT(sm) Version 89a》,也查了一些资料,最后终于用Mathematica实现了GIF的编码,这样就可以大大缩小每帧只有一小部分有变化的GIF动图文件占用的空间了。

本文主要介绍GIF编码协议的逻辑和流程。

2. Demo

请参见:demo.nb

2.1 demo for gif

导入

gifPath = 
  FileNameJoin[{NotebookDirectory[], "gif", 
    "gif_encode__global_color_table.wl"}];
Get[gifPath];
?GIFEncodeGCT`gif

使用

imageDataList = {<|
     "position" -> <|"left" -> 0, "top" -> 0|>,
     "delay_time" -> 10,
     "data" -> ConstantArray[1, {100, 100}]
     |>,
    <|
     "position" -> <|"left" -> 0, "top" -> 0|>,
     "delay_time" -> 10,
     "data" -> ConstantArray[0, {100, 100}]
     |>}~Join~Table[<|
     "position" -> <|"left" -> RandomInteger[70], 
       "top" -> RandomInteger[70]|>,
     "delay_time" -> 10,
     "data" -> RandomInteger[{0, 1}, {20, 20}]
     |>, {10}];

file = "D:/12312312312.gif";
tt = GIFEncodeGCT`gif[file,
   <|"width" -> 100, "height" -> 100|>,
   {{0, 0, 0}, {255, 255, 255}},
   imageDataList,
   Infinity];

2.2 demo for VLZW

导入

lzwPath = 
  FileNameJoin[{NotebookDirectory[], "gif", 
    "variable_length_code_LZW_compression.wl"}];
Get[lzwPath];
?VLZWCompress`VLZW

使用

VLZWCompress`VLZW[RandomInteger[6, 100], 3]

gifor's People

Contributors

sqroots avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.