-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow image change analysis with solution #16
Comments
As an afterthought: although the above code always 'runs', the transparency is only changed when the original image had an alpha channel to start with (not sure how your code handles this, maybe GDI+ automagically adds alpha?). Otherwise the alpha channel changes will do nothing as the 'unlockbits' will write back all data except the alpha channel values. To make things full-proof one would need to check whether the original image has an alpha channel. And if not, do something like this:
|
Thank you! I will review it on weekend. Do you want to create a pull request for the changes? |
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
-->Hello, No, not really. Just want to help make it a bit faster. If you decide to implement you likely want to make sure that the bitmap you will be writing in (transparency) really has a transparency channel, for example by replacing “var newImageBmp = new Bitmap(newImage);” by a variation of the ‘ToARGB’ function. Possibly checking first whether it is needed at all. From: cmk1988Sent: donderdag 6 januari 2022 16:44To: cmksoftdev/AnimatedPngCreatorCc: ez2X8pk61DHkdztgFT6O; AuthorSubject: Re: [cmksoftdev/AnimatedPngCreator] Slow image change analysis with solution (Issue #16) Thank you! I will review it on weekend. Do you want to create a pull request for the changes?—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: ***@***.***>
|
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;
}
The text was updated successfully, but these errors were encountered: