Coder Social home page Coder Social logo

dhyanb / open-imaging Goto Github PK

View Code? Open in Web Editor NEW
106.0 10.0 75.0 29.47 MB

Tools and libraries that deal with the creation and processing of images.

License: Apache License 2.0

Java 97.77% Makefile 2.23%
imaging gif decoder java frame gif-decoder gif-image gif89a gif87a animation transparency interlacing

open-imaging's People

Contributors

dhyanb avatar jacksander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open-imaging's Issues

Returned frames expose inner state

GifImage.getFrame(int) returns an internal representation of the animation.

This has two consequences:

  • Internal state is exposed to the user, akin to returning arrays or modifiable collections or exporting public fields in the API. Very bad practice in general.
  • There's no easy way to obtain the animation as a sequence of separate images.

This behavior is undocumented, and lead to a bug in my application, where I saw an animation of only the last frame.

Fortunately the API doesn't have to change in order to fix this, keeping backwards compatibility.

	public BufferedImage getFrame(int index) {
		if (img == null || index < prevIndex) { // (Re)Init
			img = new BufferedImage(width, height, 2); // 2 = ARGB
			prevImg = new BufferedImage(width, height, 2);
			prevIndex = -1;
			prevDisposal = 2;
		}
		// Draw current frame on top of previous frames
		for (int i = prevIndex + 1; i <= index; i++) {
			GifFrame fr = frames.get(i);
			drawFrame(fr);
			prevIndex = i;
			prevDisposal = fr.disposalMethod;
		}

		BufferedImage copy = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
		Graphics      g    = copy.createGraphics();
		try {
			g.drawImage(img, 0, 0, null);
		} finally {
			g.dispose();
		}
		return copy;
	}

Not all GIFs start with a clear code

While debugging some gifs that even Paint Shop Pro fails to render (but Windows, Firefox and Microsoft GIF Animator do read correctly) I found all of them had no clear code as the first code in each frame.

Removing line 202 fixed it.

bits.read(); // Skip leading clear code

However this breaks all other GIFs because now their clear code is interpreted as a color code. Need to investigate.

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.