cmksoftdev / animatedpngcreator Goto Github PK
View Code? Open in Web Editor NEWCreates animated PNG out ouf a sequence of Images.
License: GNU General Public License v3.0
Creates animated PNG out ouf a sequence of Images.
License: GNU General Public License v3.0
The animation should only render the changed sector.
Some fast flicker of colors can cause a epileptic shock. So the creator should detect it warn the user.
The project should include a class to detect unchanged pixels to avoid redundant data.
The project should also include a class to detect unchanged images and skip them.
I tried to run AnimatedPngCreator.Console using the official docker image, but got an error:
/usr/share/dotnet/sdk/2.1.403/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/home/nils/Projects/AnimatedPngCreator/AnimatedPngCreator.Console/AnimatedPngCreator.Console.csproj]
The build failed. Please fix the build errors and run again.
The docker run call:
~/Projects/AnimatedPngCreator/AnimatedPngCreator.Console$ docker run --rm -it -w $(pwd) -v $(pwd):$(pwd) microsoft/dotnet dotnet run
Maybe you can set the proper version in the project config to run in dotnet core?
The creator should throw an exception if an image is larger than the first. Now the animation is just getting corrupt.
Thanks for your code! I noticed that checking for image changes was the slowest part due to the use of GetPixel and SetPixel. The code below passes your tests and is much faster due to the use of 'LockBits' and direct access to the data. Requires the build properties to be set to 'allow unsafe code', though.
using System.Drawing;
namespace CMK
{
internal class ImageChangeAnalyser
{
private Bitmap oldImage = null;
public unsafe Image BlackoutImage(Image newImage, out bool equal)
{
equal = false;
if (newImage == null)
{
return null;
}
// Make sure we have a bitmap
var newImageBmp = new Bitmap(newImage);
// Copy of new image
var copy_new_image = new Bitmap(newImageBmp);
// Dimensions
var x = newImage.Width;
var y = newImage.Height;
var x4 = 4 * x; // argb format
// Something to do?
if (oldImage != null)
{
// Lock bits of old and new image
var o_img = oldImage.LockBits(new Rectangle(0, 0, x, y), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var n_img = newImageBmp.LockBits(new Rectangle(0, 0, x, y), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// To track equality
bool is_equal = true;
for (int j = 0; j < y; j++)
{
byte* o_row = ((byte *) o_img.Scan0) + o_img.Stride * j;
byte* n_row = ((byte * )n_img.Scan0) + n_img.Stride * j;
for (int i = 0; i < x4; i+=4)
{
// Compare b, g, and r values (+0, +1, +2)
if (o_row[i+0] == n_row[i+0] && o_row[i+1] == n_row[i+1] && o_row[i+2] == n_row[i+2])
{
// For compatibility with tests
n_row[i + 0] = 255;
n_row[i + 1] = 255;
n_row[i + 2] = 255;
// Set 'A' value(+3) of new image to 0: fully transparent (whatever the other colors!)
n_row[i + 3] = 0;
}
else
{
is_equal = false;
}
}
}
// Unlock bits
oldImage.UnlockBits(o_img);
newImageBmp.UnlockBits(n_img);
// Update equality
equal = is_equal;
}
// old image is current new image (but without our transparancy changes, so use copy0
oldImage = copy_new_image;
// Return bitmap with transparance changes
return newImageBmp;
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.