From 9d69cb51bd5985b18725f53372f9f44d510f4722 Mon Sep 17 00:00:00 2001 From: moosecrab Date: Tue, 24 Oct 2023 22:04:47 -0700 Subject: [PATCH] Initial commit --- .gitignore | 471 ++++++++++++++++++++ pngchunk.sln | 20 + pngchunk/My Project/Application.Designer.vb | 13 + pngchunk/My Project/Application.myapp | 10 + pngchunk/My Project/AssemblyInfo.vb | 35 ++ pngchunk/My Project/Resources.Designer.vb | 62 +++ pngchunk/My Project/Resources.resx | 117 +++++ pngchunk/My Project/Settings.Designer.vb | 73 +++ pngchunk/My Project/Settings.settings | 7 + pngchunk/My Project/app.manifest | 48 ++ pngchunk/pngchunk.vb | 172 +++++++ pngchunk/pngchunk.vbproj | 157 +++++++ 12 files changed, 1185 insertions(+) create mode 100755 .gitignore create mode 100755 pngchunk.sln create mode 100755 pngchunk/My Project/Application.Designer.vb create mode 100755 pngchunk/My Project/Application.myapp create mode 100755 pngchunk/My Project/AssemblyInfo.vb create mode 100755 pngchunk/My Project/Resources.Designer.vb create mode 100755 pngchunk/My Project/Resources.resx create mode 100755 pngchunk/My Project/Settings.Designer.vb create mode 100755 pngchunk/My Project/Settings.settings create mode 100755 pngchunk/My Project/app.manifest create mode 100755 pngchunk/pngchunk.vb create mode 100755 pngchunk/pngchunk.vbproj diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..4c2b1ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,471 @@ +# Created by https://www.toptal.com/developers/gitignore/api/visualbasic,visualstudio,dotnetcore +# Edit at https://www.toptal.com/developers/gitignore?templates=visualbasic,visualstudio,dotnetcore + +### DotnetCore ### +# .NET Core build folders +bin/ +obj/ + +# Common node modules locations +/node_modules +/wwwroot/node_modules + +### VisualBasic ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +.DS_Store +.Trashes +*.vbw +*.csi +*.exp +*.lib +*.lvw +*.dca +*.scc +*.tmp +*.exe +*.bat +*.bak +*.zip +*.old +*.enc +*.key +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### VisualStudio ### +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.msix + +# JetBrains Rider +*.sln.iml + +### VisualStudio Patch ### +# Additional files built by Visual Studio + +# End of https://www.toptal.com/developers/gitignore/api/visualbasic,visualstudio,dotnetcore diff --git a/pngchunk.sln b/pngchunk.sln new file mode 100755 index 0000000..37033cb --- /dev/null +++ b/pngchunk.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "pngchunk", "pngchunk\pngchunk.vbproj", "{097E6F35-4871-42E4-8032-414A0672169A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {097E6F35-4871-42E4-8032-414A0672169A}.Debug|x86.ActiveCfg = Debug|x86 + {097E6F35-4871-42E4-8032-414A0672169A}.Debug|x86.Build.0 = Debug|x86 + {097E6F35-4871-42E4-8032-414A0672169A}.Release|x86.ActiveCfg = Release|x86 + {097E6F35-4871-42E4-8032-414A0672169A}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/pngchunk/My Project/Application.Designer.vb b/pngchunk/My Project/Application.Designer.vb new file mode 100755 index 0000000..126d785 --- /dev/null +++ b/pngchunk/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.34209 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/pngchunk/My Project/Application.myapp b/pngchunk/My Project/Application.myapp new file mode 100755 index 0000000..23b627f --- /dev/null +++ b/pngchunk/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/pngchunk/My Project/AssemblyInfo.vb b/pngchunk/My Project/AssemblyInfo.vb new file mode 100755 index 0000000..1fbcf39 --- /dev/null +++ b/pngchunk/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/pngchunk/My Project/Resources.Designer.vb b/pngchunk/My Project/Resources.Designer.vb new file mode 100755 index 0000000..09c0f83 --- /dev/null +++ b/pngchunk/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.34209 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("pngchunk.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/pngchunk/My Project/Resources.resx b/pngchunk/My Project/Resources.resx new file mode 100755 index 0000000..ffecec8 --- /dev/null +++ b/pngchunk/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/pngchunk/My Project/Settings.Designer.vb b/pngchunk/My Project/Settings.Designer.vb new file mode 100755 index 0000000..8d04473 --- /dev/null +++ b/pngchunk/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.34209 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.pngchunk.My.MySettings + Get + Return Global.pngchunk.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/pngchunk/My Project/Settings.settings b/pngchunk/My Project/Settings.settings new file mode 100755 index 0000000..377f56d --- /dev/null +++ b/pngchunk/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/pngchunk/My Project/app.manifest b/pngchunk/My Project/app.manifest new file mode 100755 index 0000000..cbe08de --- /dev/null +++ b/pngchunk/My Project/app.manifest @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pngchunk/pngchunk.vb b/pngchunk/pngchunk.vb new file mode 100755 index 0000000..f357a4e --- /dev/null +++ b/pngchunk/pngchunk.vb @@ -0,0 +1,172 @@ +Module pngchunk + + Sub Main() + If My.Application.CommandLineArgs.Count = 0 Then + Console.WriteLine("pngchunk - http://long-cat.net") + Console.WriteLine("Usage: pngchunk [options] file.png") + Console.WriteLine() + Console.WriteLine("Options:" & vbNewLine & + "-x extract embedded PNG files and non-PNG data") + Exit Sub + End If + + Dim extract As Boolean + Dim filename As String = String.Empty + Dim pngcount, datcount As Integer + + For Each opt In My.Application.CommandLineArgs + If opt = "-x" Or opt = "/x" Then + extract = True + Else + filename = opt + End If + Next + + If Not FileIO.FileSystem.FileExists(filename) Then + Console.WriteLine("File {0} not found!", filename) + End If + Dim fs As New IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read) + Dim fi As New IO.FileInfo(filename) + + While Not fs.Position = fs.Length + Dim startposition As Long = fs.Position + FindHeader(fs) + + If fs.Position - 8 <> startposition And fs.Position <> fs.Length Then + Console.WriteLine(">> Skipped {0} bytes of non-png data", fs.Position - 8 - startposition) + If extract Then + CopyPart(filename, fi.FullName & "." & datcount & ".dat", startposition, fs.Position - 8 - startposition) + datcount += 1 + End If + + ElseIf fs.Position = fs.Length Then + Console.WriteLine(">> Skipped {0} bytes of non-png data", fs.Position - startposition) + If extract Then + CopyPart(filename, fi.FullName & "." & datcount & ".dat", startposition, fs.Position - startposition) + datcount += 1 + End If + + End If + + startposition = fs.Position - 8 + + If fs.Position = fs.Length Then + Console.WriteLine("End of file") + fs.Close() + Exit Sub + Else + Console.WriteLine("-- PNG header at {0}", fs.Position - 8) + End If + + + Dim buf() As Byte + Dim len As Integer + + Dim chunklength As UInt32 + Dim chunktype As String = String.Empty + + While chunktype <> "IEND" AndAlso fs.Position <> fs.Length + ReDim buf(3) + len = fs.Read(buf, 0, 4) + If len <> 4 Then + Console.WriteLine("Incomplete chunk length header") + Exit While + End If + + 'big endian + chunklength = &H1000000L * buf(0) + &H10000L * buf(1) + &H100L * buf(2) + buf(3) + Console.Write("{0,10}:", chunklength) + + ReDim buf(chunklength + 3) + len = fs.Read(buf, 0, chunklength + 4) + If len <> chunklength + 4 Then + Console.WriteLine("Incomplete chunk data") + Exit While + End If + chunktype = System.Text.Encoding.ASCII.GetString(buf, 0, 4) + Console.Write(chunktype & " ") + Dim datachecksum As UInt32 = Crc32.ComputeChecksum(buf) + + ReDim buf(3) + len = fs.Read(buf, 0, 4) + If len <> 4 Then + Console.WriteLine("Incomplete CRC data") + End If + Dim chunkchecksum As UInt32 = &H1000000L * buf(0) + &H10000L * buf(1) + &H100L * buf(2) + buf(3) + If chunkchecksum = datachecksum Then + Console.Write("ok") + Else + Console.Write("INVALID CRC") + End If + Console.WriteLine() + + End While + + If extract Then + CopyPart(filename, fi.FullName & "." & pngcount & ".png", startposition, fs.Position - startposition) + pngcount += 1 + End If + + End While + + fs.Close() + End Sub + + Public Sub FindHeader(fs As IO.FileStream) + Dim header() As Byte = {&H89, &H50, &H4E, &H47, &HD, &HA, &H1A, &HA} + Dim i As Integer = 0 + Dim startposition As Long = fs.Position + While i < 8 + If fs.ReadByte = header(i) Then + i += 1 + Else + i = 0 + End If + If fs.Position = fs.Length Then + Exit Sub + End If + End While + End Sub + + Public Sub CopyPart(srcfile As String, destfile As String, offset As Long, bytes As Long) + Dim srcfs As New IO.FileStream(srcfile, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read) + Dim destfs As New IO.FileStream(destfile, IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read) + srcfs.Seek(offset, IO.SeekOrigin.Begin) + Dim buf(bytes) As Byte + Dim len As Integer = srcfs.Read(buf, 0, bytes) + destfs.Write(buf, 0, len) + srcfs.Close() + destfs.Close() + End Sub + + Public Class Crc32 + Shared table As UInteger() + + Shared Sub New() + Dim poly As UInteger = &HEDB88320UI + table = New UInteger(255) {} + Dim temp As UInteger = 0 + For i As UInteger = 0 To table.Length - 1 + temp = i + For j As Integer = 8 To 1 Step -1 + If (temp And 1) = 1 Then + temp = CUInt((temp >> 1) Xor poly) + Else + temp >>= 1 + End If + Next + table(i) = temp + Next + End Sub + + Public Shared Function ComputeChecksum(bytes As Byte()) As UInteger + Dim crc As UInteger = &HFFFFFFFFUI + For i As Integer = 0 To bytes.Length - 1 + Dim index As Byte = CByte(((crc) And &HFF) Xor bytes(i)) + crc = CUInt((crc >> 8) Xor table(index)) + Next + Return Not crc + End Function + End Class + +End Module diff --git a/pngchunk/pngchunk.vbproj b/pngchunk/pngchunk.vbproj new file mode 100755 index 0000000..a988012 --- /dev/null +++ b/pngchunk/pngchunk.vbproj @@ -0,0 +1,157 @@ + + + + Debug + x86 + + + + + {097E6F35-4871-42E4-8032-414A0672169A} + Exe + pngchunk.pngchunk + pngchunk + pngchunk + 512 + Console + v4.0 + Client + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + x86 + true + full + true + true + bin\Debug\ + pngchunk.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + x86 + pdbonly + false + true + true + bin\Release\ + pngchunk.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + My Project\app.manifest + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + Microsoft .NET Framework 4 Client Profile %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file