mirror of
https://github.com/TheShadowEevee/libWiiSharp.git
synced 2025-01-11 15:38:51 -06:00
Update TPL for .Net 6, Copyright Year Update
This commit is contained in:
parent
47dc604f45
commit
48efe73686
24 changed files with 125 additions and 93 deletions
|
@ -3,14 +3,14 @@ using System.Resources;
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("libWiiSharp_Modified")]
|
||||
[assembly: AssemblyDescription("A wii related .NET library modified to add features for othe programs.")]
|
||||
[assembly: AssemblyDescription("A wii related .NET library modified to add features for other programs.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Leathl,SC reproductions")]
|
||||
[assembly: AssemblyProduct("libWiiSharp_Modified")]
|
||||
[assembly: AssemblyCopyright("Copyright © Leathl 2011, Copyright © Github Contributors 2020")]
|
||||
[assembly: AssemblyCopyright("Copyright © Leathl 2011, Copyright © Github Contributors 2020-2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(true)]
|
||||
[assembly: Guid("af701263-5875-4866-9c09-d7f62e9f0ff0")]
|
||||
[assembly: AssemblyFileVersion("0.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.6.0.0")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
[assembly: AssemblyVersion("0.4.0.0")]
|
||||
[assembly: AssemblyVersion("0.6.0.0")]
|
2
BNS.cs
2
BNS.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
2
Brlan.cs
2
Brlan.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
2
Brlyt.cs
2
Brlyt.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright(C) 2009 Leathl
|
||||
* Copyright(C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
9
Licenses/SkiaSharp.license
Normal file
9
Licenses/SkiaSharp.license
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
Copyright (c) 2015-2016 Xamarin, Inc.
|
||||
Copyright (c) 2017-2018 Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2
Lz77.cs
2
Lz77.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -36,7 +36,9 @@ namespace libWiiSharp
|
|||
public class NusClient : IDisposable
|
||||
{
|
||||
private const string nusUrl = "http://nus.cdn.shop.wii.com/ccs/download/";
|
||||
#pragma warning disable SYSLIB0014 // Type or member is obsolete
|
||||
private readonly WebClient wcNus = new WebClient();
|
||||
#pragma warning restore SYSLIB0014 // Type or member is obsolete
|
||||
private bool useLocalFiles;
|
||||
private bool continueWithoutTicket;
|
||||
private bool isDisposed;
|
||||
|
@ -182,7 +184,6 @@ namespace libWiiSharp
|
|||
if (!File.Exists("cetk") && !continueWithoutTicket)
|
||||
{
|
||||
FireDebug(" Downloading Ticket...");
|
||||
Console.WriteLine("Downloading");
|
||||
try
|
||||
{
|
||||
byte[] tikArray = wcNus.DownloadData(str2 + "cetk");
|
||||
|
@ -193,7 +194,6 @@ namespace libWiiSharp
|
|||
throw new Exception("CETK Doesn't Exist and Downloading Ticket Failed:\n" + ex.Message);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Continuing");
|
||||
FireDebug("Parsing Ticket...");
|
||||
Ticket tik = Ticket.Load("cetk");
|
||||
FireProgress(40);
|
||||
|
@ -474,6 +474,7 @@ namespace libWiiSharp
|
|||
byte[] bytes = BitConverter.GetBytes(tmd.Contents[contentIndex].Index);
|
||||
numArray[0] = bytes[1];
|
||||
numArray[1] = bytes[0];
|
||||
#pragma warning disable SYSLIB0022 // Type or member is obsolete
|
||||
RijndaelManaged rijndaelManaged = new RijndaelManaged
|
||||
{
|
||||
Mode = CipherMode.CBC,
|
||||
|
@ -483,6 +484,7 @@ namespace libWiiSharp
|
|||
Key = titleKey,
|
||||
IV = numArray
|
||||
};
|
||||
#pragma warning restore SYSLIB0022 // Type or member is obsolete
|
||||
ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor();
|
||||
MemoryStream memoryStream = new MemoryStream(content);
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# libWiiSharp
|
||||
|
||||
libWiiSharp is a Wii related .NET (2.0+) library.
|
||||
libWiiSharp is a Wii related .NET library running on .Net 6 LTS.
|
||||
It can be used with any .NET language to easily develop Wii related applications.
|
||||
|
||||
It was originally created by Leathl, and the maintainer of [this repo](https://github.com/TheShadowEevee/libWiiSharp) is [TheShadowEevee](https://github.com/TheShadowEevee).
|
||||
Originally created by Leathl, The current maintainer of [this repo](https://github.com/TheShadowEevee/libWiiSharp) is [TheShadowEevee](https://github.com/TheShadowEevee).
|
||||
|
||||
All public functions are documented and most should be pretty self-explanatory.
|
||||
|
||||
|
@ -16,6 +16,8 @@ If you want to contribute, you can do so at [the github repo](https://github.com
|
|||
libWiiSharp is released under the terms of the GNU General Public License v3.
|
||||
See the LICENSE file for more info
|
||||
|
||||
TPL code uses SkiaSharp, which is released under the MIT License. See the Licenses folder for information.
|
||||
|
||||
## Credits
|
||||
From the original libWiiSharp:
|
||||
- Xuzz, SquidMan, megazig, Matt_P, Omega and The Lemon Man for Wii.py
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
2
TMD.cs
2
TMD.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
127
TPL.cs
127
TPL.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -22,8 +22,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using SkiaSharp;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
@ -147,11 +146,11 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
public static TPL FromImage(
|
||||
Image img,
|
||||
SKBitmap img,
|
||||
TPL_TextureFormat tplFormat,
|
||||
TPL_PaletteFormat paletteFormat = TPL_PaletteFormat.RGB5A3)
|
||||
{
|
||||
return FromImages(new Image[1] { img }, new TPL_TextureFormat[1]
|
||||
return FromImages(new SKBitmap[1] { img }, new TPL_TextureFormat[1]
|
||||
{
|
||||
tplFormat
|
||||
}, new TPL_PaletteFormat[1] { paletteFormat });
|
||||
|
@ -167,10 +166,10 @@ namespace libWiiSharp
|
|||
throw new Exception("You must specify a format for each image!");
|
||||
}
|
||||
|
||||
List<Image> imageList = new List<Image>();
|
||||
List<SKBitmap> imageList = new List<SKBitmap>();
|
||||
foreach (string imagePath in imagePaths)
|
||||
{
|
||||
imageList.Add(Image.FromFile(imagePath));
|
||||
imageList.Add(SKBitmap.Decode(imagePath));
|
||||
}
|
||||
|
||||
TPL tpl = new TPL();
|
||||
|
@ -179,7 +178,7 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
public static TPL FromImages(
|
||||
Image[] images,
|
||||
SKBitmap[] images,
|
||||
TPL_TextureFormat[] tplFormats,
|
||||
TPL_PaletteFormat[] paletteFormats)
|
||||
{
|
||||
|
@ -240,11 +239,11 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
public void CreateFromImage(
|
||||
Image img,
|
||||
SKBitmap img,
|
||||
TPL_TextureFormat tplFormat,
|
||||
TPL_PaletteFormat paletteFormat = TPL_PaletteFormat.RGB5A3)
|
||||
{
|
||||
PrivCreateFromImages(new Image[1] { img }, new TPL_TextureFormat[1]
|
||||
PrivCreateFromImages(new SKBitmap[1] { img }, new TPL_TextureFormat[1]
|
||||
{
|
||||
tplFormat
|
||||
}, new TPL_PaletteFormat[1] { paletteFormat });
|
||||
|
@ -260,17 +259,17 @@ namespace libWiiSharp
|
|||
throw new Exception("You must specify a format for each image!");
|
||||
}
|
||||
|
||||
List<Image> imageList = new List<Image>();
|
||||
List<SKBitmap> imageList = new List<SKBitmap>();
|
||||
foreach (string imagePath in imagePaths)
|
||||
{
|
||||
imageList.Add(Image.FromFile(imagePath));
|
||||
imageList.Add(SKBitmap.Decode(imagePath));
|
||||
}
|
||||
|
||||
PrivCreateFromImages(imageList.ToArray(), tplFormats, paletteFormats);
|
||||
}
|
||||
|
||||
public void CreateFromImages(
|
||||
Image[] images,
|
||||
SKBitmap[] images,
|
||||
TPL_TextureFormat[] tplFormats,
|
||||
TPL_PaletteFormat[] paletteFormats)
|
||||
{
|
||||
|
@ -322,12 +321,12 @@ namespace libWiiSharp
|
|||
return ToMemoryStream().ToArray();
|
||||
}
|
||||
|
||||
public Image ExtractTexture()
|
||||
public SKBitmap ExtractTexture()
|
||||
{
|
||||
return ExtractTexture(0);
|
||||
}
|
||||
|
||||
public Image ExtractTexture(int index)
|
||||
public SKBitmap ExtractTexture(int index)
|
||||
{
|
||||
byte[] data = tplTextureHeaders[index].TextureFormat switch
|
||||
{
|
||||
|
@ -359,32 +358,51 @@ namespace libWiiSharp
|
|||
File.Delete(savePath);
|
||||
}
|
||||
|
||||
Image texture = ExtractTexture(index);
|
||||
SKBitmap texture = ExtractTexture(index);
|
||||
switch (Path.GetExtension(savePath).ToLower())
|
||||
{
|
||||
case ".tif":
|
||||
case ".tiff":
|
||||
texture.Save(savePath, ImageFormat.Tiff);
|
||||
case ".webp":
|
||||
SKData webp = SKImage.FromBitmap(texture).Encode(SKEncodedImageFormat.Webp, 100);
|
||||
using (var filestream = File.OpenWrite(savePath))
|
||||
{
|
||||
webp.SaveTo(filestream);
|
||||
}
|
||||
break;
|
||||
case ".bmp":
|
||||
texture.Save(savePath, ImageFormat.Bmp);
|
||||
SKData bmp = SKImage.FromBitmap(texture).Encode(SKEncodedImageFormat.Bmp, 100);
|
||||
using (var filestream = File.OpenWrite(savePath))
|
||||
{
|
||||
bmp.SaveTo(filestream);
|
||||
}
|
||||
break;
|
||||
case ".gif":
|
||||
texture.Save(savePath, ImageFormat.Gif);
|
||||
SKData gif = SKImage.FromBitmap(texture).Encode(SKEncodedImageFormat.Gif, 100);
|
||||
using (var filestream = File.OpenWrite(savePath))
|
||||
{
|
||||
gif.SaveTo(filestream);
|
||||
}
|
||||
break;
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
texture.Save(savePath, ImageFormat.Jpeg);
|
||||
SKData jpeg = SKImage.FromBitmap(texture).Encode(SKEncodedImageFormat.Jpeg, 100);
|
||||
using (var filestream = File.OpenWrite(savePath))
|
||||
{
|
||||
jpeg.SaveTo(filestream);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
texture.Save(savePath, ImageFormat.Png);
|
||||
SKData png = SKImage.FromBitmap(texture).Encode(SKEncodedImageFormat.Png, 100);
|
||||
using (var filestream = File.OpenWrite(savePath))
|
||||
{
|
||||
png.SaveTo(filestream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Image[] ExtractAllTextures()
|
||||
public SKBitmap[] ExtractAllTextures()
|
||||
{
|
||||
List<Image> imageList = new List<Image>();
|
||||
List<SKBitmap> imageList = new List<SKBitmap>();
|
||||
for (int index = 0; index < tplHeader.NumOfTextures; ++index)
|
||||
{
|
||||
imageList.Add(ExtractTexture(index));
|
||||
|
@ -411,10 +429,10 @@ namespace libWiiSharp
|
|||
TPL_TextureFormat tplFormat,
|
||||
TPL_PaletteFormat paletteFormat = TPL_PaletteFormat.RGB5A3)
|
||||
{
|
||||
AddTexture(Image.FromFile(imagePath), tplFormat, paletteFormat);
|
||||
AddTexture(SKBitmap.Decode(imagePath), tplFormat, paletteFormat);
|
||||
}
|
||||
|
||||
public void AddTexture(Image img, TPL_TextureFormat tplFormat, TPL_PaletteFormat paletteFormat = TPL_PaletteFormat.RGB5A3)
|
||||
public void AddTexture(SKBitmap img, TPL_TextureFormat tplFormat, TPL_PaletteFormat paletteFormat = TPL_PaletteFormat.RGB5A3)
|
||||
{
|
||||
TPL_TextureEntry tplTextureEntry = new TPL_TextureEntry();
|
||||
TPL_TextureHeader tplTextureHeader = new TPL_TextureHeader();
|
||||
|
@ -465,10 +483,10 @@ namespace libWiiSharp
|
|||
return (TPL_PaletteFormat)tplPaletteHeaders[index].PaletteFormat;
|
||||
}
|
||||
|
||||
public Size GetTextureSize(int index)
|
||||
/*public Size GetTextureSize(int index)
|
||||
{
|
||||
return new Size(tplTextureHeaders[index].TextureWidth, tplTextureHeaders[index].TextureHeight);
|
||||
}
|
||||
}*/
|
||||
|
||||
private void WriteToStream(Stream writeStream)
|
||||
{
|
||||
|
@ -657,7 +675,7 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
private void PrivCreateFromImages(
|
||||
Image[] images,
|
||||
SKBitmap[] images,
|
||||
TPL_TextureFormat[] tplFormats,
|
||||
TPL_PaletteFormat[] paletteFormats)
|
||||
{
|
||||
|
@ -670,7 +688,7 @@ namespace libWiiSharp
|
|||
tplHeader.NumOfTextures = (uint)images.Length;
|
||||
for (int index = 0; index < images.Length; ++index)
|
||||
{
|
||||
Image image = images[index];
|
||||
SKBitmap image = images[index];
|
||||
TPL_TextureEntry tplTextureEntry = new TPL_TextureEntry();
|
||||
TPL_TextureHeader tplTextureHeader = new TPL_TextureHeader();
|
||||
TPL_PaletteHeader tplPaletteHeader = new TPL_PaletteHeader();
|
||||
|
@ -695,33 +713,30 @@ namespace libWiiSharp
|
|||
}
|
||||
}
|
||||
|
||||
private byte[] ImageToTpl(Image img, TPL_TextureFormat tplFormat)
|
||||
private byte[] ImageToTpl(SKBitmap img, TPL_TextureFormat tplFormat)
|
||||
{
|
||||
return tplFormat switch
|
||||
{
|
||||
TPL_TextureFormat.I4 => ToI4((Bitmap)img),
|
||||
TPL_TextureFormat.I8 => ToI8((Bitmap)img),
|
||||
TPL_TextureFormat.IA4 => ToIA4((Bitmap)img),
|
||||
TPL_TextureFormat.IA8 => ToIA8((Bitmap)img),
|
||||
TPL_TextureFormat.RGB565 => ToRGB565((Bitmap)img),
|
||||
TPL_TextureFormat.RGB5A3 => ToRGB5A3((Bitmap)img),
|
||||
TPL_TextureFormat.RGBA8 => ToRGBA8((Bitmap)img),
|
||||
TPL_TextureFormat.I4 => ToI4(img),
|
||||
TPL_TextureFormat.I8 => ToI8(img),
|
||||
TPL_TextureFormat.IA4 => ToIA4(img),
|
||||
TPL_TextureFormat.IA8 => ToIA8(img),
|
||||
TPL_TextureFormat.RGB565 => ToRGB565(img),
|
||||
TPL_TextureFormat.RGB5A3 => ToRGB5A3(img),
|
||||
TPL_TextureFormat.RGBA8 => ToRGBA8(img),
|
||||
TPL_TextureFormat.CI4 or TPL_TextureFormat.CI8 or TPL_TextureFormat.CI14X2 => new byte[0],
|
||||
_ => throw new FormatException("Format not supported!\nCurrently, images can only be converted to the following formats:\nI4, I8, IA4, IA8, RGB565, RGB5A3, RGBA8, CI4, CI8 , CI14X2."),
|
||||
};
|
||||
}
|
||||
|
||||
private uint[] ImageToRgba(Image img)
|
||||
private uint[] ImageToRgba(SKBitmap bitmap)
|
||||
{
|
||||
Bitmap bitmap = (Bitmap)img;
|
||||
BitmapData bitmapdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
byte[] numArray = new byte[bitmapdata.Height * Math.Abs(bitmapdata.Stride)];
|
||||
Marshal.Copy(bitmapdata.Scan0, numArray, 0, numArray.Length);
|
||||
bitmap.UnlockBits(bitmapdata);
|
||||
byte[] numArray = new byte[bitmap.Height * (Math.Abs(bitmap.Width) * 4)];
|
||||
Marshal.Copy(bitmap.GetAddress(0, 0), numArray, 0, numArray.Length);
|
||||
return Shared.ByteArrayToUIntArray(numArray);
|
||||
}
|
||||
|
||||
private Bitmap RgbaToImage(byte[] data, int width, int height)
|
||||
private SKBitmap RgbaToImage(byte[] data, int width, int height)
|
||||
{
|
||||
if (width == 0)
|
||||
{
|
||||
|
@ -733,12 +748,10 @@ namespace libWiiSharp
|
|||
height = 1;
|
||||
}
|
||||
|
||||
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
SKBitmap bitmap = new SKBitmap(width, height);
|
||||
try
|
||||
{
|
||||
BitmapData bitmapdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
|
||||
Marshal.Copy(data, 0, bitmapdata.Scan0, data.Length);
|
||||
bitmap.UnlockBits(bitmapdata);
|
||||
Marshal.Copy(data, 0, bitmap.GetAddress(0, 0), data.Length);
|
||||
return bitmap;
|
||||
}
|
||||
catch
|
||||
|
@ -854,7 +867,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToRGBA8(Bitmap img)
|
||||
private byte[] ToRGBA8(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
@ -959,7 +972,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToRGB5A3(Bitmap img)
|
||||
private byte[] ToRGB5A3(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
@ -1038,7 +1051,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToRGB565(Bitmap img)
|
||||
private byte[] ToRGB565(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
@ -1103,7 +1116,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToI4(Bitmap img)
|
||||
private byte[] ToI4(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
@ -1163,7 +1176,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToI8(Bitmap img)
|
||||
private byte[] ToI8(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
@ -1222,7 +1235,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToIA4(Bitmap img)
|
||||
private byte[] ToIA4(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
@ -1281,7 +1294,7 @@ namespace libWiiSharp
|
|||
return Shared.UIntArrayToByteArray(array);
|
||||
}
|
||||
|
||||
private byte[] ToIA8(Bitmap img)
|
||||
private byte[] ToIA8(SKBitmap img)
|
||||
{
|
||||
uint[] rgba = ImageToRgba(img);
|
||||
int width = img.Width;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -489,6 +489,7 @@ namespace libWiiSharp
|
|||
byte[] numArray = commonKeyIndex == 1 ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey();
|
||||
byte[] bytes = BitConverter.GetBytes(Shared.Swap(titleId));
|
||||
Array.Resize<byte>(ref bytes, 16);
|
||||
#pragma warning disable SYSLIB0022 // Type or member is obsolete
|
||||
RijndaelManaged rijndaelManaged = new RijndaelManaged
|
||||
{
|
||||
Mode = CipherMode.CBC,
|
||||
|
@ -498,6 +499,7 @@ namespace libWiiSharp
|
|||
Key = numArray,
|
||||
IV = bytes
|
||||
};
|
||||
#pragma warning restore SYSLIB0022 // Type or member is obsolete
|
||||
ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor();
|
||||
MemoryStream memoryStream = new MemoryStream(encryptedTitleKey);
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
|
||||
|
@ -514,6 +516,7 @@ namespace libWiiSharp
|
|||
byte[] numArray = commonKeyIndex == 1 ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey();
|
||||
byte[] bytes = BitConverter.GetBytes(Shared.Swap(titleId));
|
||||
Array.Resize<byte>(ref bytes, 16);
|
||||
#pragma warning disable SYSLIB0022 // Type or member is obsolete
|
||||
RijndaelManaged rijndaelManaged = new RijndaelManaged
|
||||
{
|
||||
Mode = CipherMode.CBC,
|
||||
|
@ -523,6 +526,7 @@ namespace libWiiSharp
|
|||
Key = numArray,
|
||||
IV = bytes
|
||||
};
|
||||
#pragma warning restore SYSLIB0022 // Type or member is obsolete
|
||||
ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor();
|
||||
MemoryStream memoryStream = new MemoryStream(decryptedTitleKey);
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Read);
|
||||
|
|
2
U8.cs
2
U8.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
6
WAD.cs
6
WAD.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -1007,6 +1007,7 @@ namespace libWiiSharp
|
|||
byte[] bytes = BitConverter.GetBytes(tmd.Contents[contentIndex].Index);
|
||||
numArray[0] = bytes[1];
|
||||
numArray[1] = bytes[0];
|
||||
#pragma warning disable SYSLIB0022 // Type or member is obsolete
|
||||
RijndaelManaged rijndaelManaged = new RijndaelManaged
|
||||
{
|
||||
Mode = CipherMode.CBC,
|
||||
|
@ -1016,6 +1017,7 @@ namespace libWiiSharp
|
|||
Key = titleKey,
|
||||
IV = numArray
|
||||
};
|
||||
#pragma warning restore SYSLIB0022 // Type or member is obsolete
|
||||
ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor();
|
||||
MemoryStream memoryStream = new MemoryStream(content);
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
|
||||
|
@ -1034,6 +1036,7 @@ namespace libWiiSharp
|
|||
byte[] bytes = BitConverter.GetBytes(tmd.Contents[contentIndex].Index);
|
||||
numArray[0] = bytes[1];
|
||||
numArray[1] = bytes[0];
|
||||
#pragma warning disable SYSLIB0022 // Type or member is obsolete
|
||||
RijndaelManaged rijndaelManaged = new RijndaelManaged
|
||||
{
|
||||
Mode = CipherMode.CBC,
|
||||
|
@ -1043,6 +1046,7 @@ namespace libWiiSharp
|
|||
Key = titleKey,
|
||||
IV = numArray
|
||||
};
|
||||
#pragma warning restore SYSLIB0022 // Type or member is obsolete
|
||||
ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor();
|
||||
MemoryStream memoryStream = new MemoryStream(content);
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Read);
|
||||
|
|
2
Wave.cs
2
Wave.cs
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of libWiiSharp
|
||||
* Copyright (C) 2009 Leathl
|
||||
* Copyright (C) 2020 - 2021 Github Contributors
|
||||
* Copyright (C) 2020 - 2022 TheShadowEevee, Github Contributors
|
||||
*
|
||||
* libWiiSharp is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<OutputType>Library</OutputType>
|
||||
<ApplicationVersion>0.4.0.0</ApplicationVersion>
|
||||
<ApplicationVersion>0.6.0.0</ApplicationVersion>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
<Nullable>annotations</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<RegisterForComInterop>true</RegisterForComInterop>
|
||||
|
@ -17,13 +18,10 @@
|
|||
<ItemGroup>
|
||||
<Content Include=".gitignore" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.310801">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Log.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SkiaSharp" Version="2.80.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in a new issue