mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-04 22:06:06 +02:00
Fix print upload size
This commit is contained in:
+50
-5
@@ -95,11 +95,9 @@ namespace VRCX
|
|||||||
{
|
{
|
||||||
var newSize = Math.Max(image.Width, image.Height);
|
var newSize = Math.Max(image.Width, image.Height);
|
||||||
var newImage = new Bitmap(newSize, newSize);
|
var newImage = new Bitmap(newSize, newSize);
|
||||||
using (var graphics = Graphics.FromImage(newImage))
|
using var graphics = Graphics.FromImage(newImage);
|
||||||
{
|
graphics.Clear(Color.Transparent);
|
||||||
graphics.Clear(Color.Transparent);
|
graphics.DrawImage(image, new Rectangle((newSize - image.Width) / 2, (newSize - image.Height) / 2, image.Width, image.Height));
|
||||||
graphics.DrawImage(image, new Rectangle((newSize - image.Width) / 2, (newSize - image.Height) / 2, image.Width, image.Height));
|
|
||||||
}
|
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
image = newImage;
|
image = newImage;
|
||||||
}
|
}
|
||||||
@@ -141,6 +139,53 @@ namespace VRCX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] ResizePrintImage(byte[] imageData)
|
||||||
|
{
|
||||||
|
var inputImage = ResizeImageToFitLimits(imageData, false, 1920, 1080);
|
||||||
|
using var fileMemoryStream = new MemoryStream(inputImage);
|
||||||
|
var image = new Bitmap(fileMemoryStream);
|
||||||
|
|
||||||
|
// increase size to 1920x1080
|
||||||
|
if (image.Width < 1920 || image.Height < 1080)
|
||||||
|
{
|
||||||
|
var newHeight = image.Height;
|
||||||
|
var newWidth = image.Width;
|
||||||
|
if (image.Width < 1920)
|
||||||
|
{
|
||||||
|
newWidth = 1920;
|
||||||
|
newHeight = (int)Math.Round(image.Height / (image.Width / (double)newWidth));
|
||||||
|
}
|
||||||
|
if (image.Height < 1080)
|
||||||
|
{
|
||||||
|
newHeight = 1080;
|
||||||
|
newWidth = (int)Math.Round(image.Width / (image.Height / (double)newHeight));
|
||||||
|
}
|
||||||
|
var resizedImage = new Bitmap(1920, 1080);
|
||||||
|
using var graphics1 = Graphics.FromImage(resizedImage);
|
||||||
|
graphics1.Clear(Color.White);
|
||||||
|
var x = (1920 - newWidth) / 2;
|
||||||
|
var y = (1080 - newHeight) / 2;
|
||||||
|
graphics1.DrawImage(image, new Rectangle(x, y, newWidth, newHeight));
|
||||||
|
image.Dispose();
|
||||||
|
image = resizedImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add white border
|
||||||
|
// wtf are these magic numbers
|
||||||
|
const int xOffset = 64; // 2048 / 32
|
||||||
|
const int yOffset = 69; // 1440 / 20.869
|
||||||
|
var newImage = new Bitmap(2048, 1440);
|
||||||
|
using var graphics = Graphics.FromImage(newImage);
|
||||||
|
graphics.Clear(Color.White);
|
||||||
|
graphics.DrawImage(image, new Rectangle(xOffset, yOffset, image.Width, image.Height));
|
||||||
|
image.Dispose();
|
||||||
|
image = newImage;
|
||||||
|
|
||||||
|
using var imageSaveMemoryStream = new MemoryStream();
|
||||||
|
image.Save(imageSaveMemoryStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||||
|
return imageSaveMemoryStream.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes the signature of the file represented by the specified base64-encoded string using the librsync library.
|
/// Computes the signature of the file represented by the specified base64-encoded string using the librsync library.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+1
-1
@@ -306,7 +306,7 @@ namespace VRCX
|
|||||||
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||||
var requestStream = request.GetRequestStream();
|
var requestStream = request.GetRequestStream();
|
||||||
var imageData = options["imageData"] as string;
|
var imageData = options["imageData"] as string;
|
||||||
var fileToUpload = AppApi.Instance.ResizeImageToFitLimits(Convert.FromBase64String(imageData), false, 1920, 1080);
|
var fileToUpload = AppApi.Instance.ResizePrintImage(Convert.FromBase64String(imageData));
|
||||||
const string fileFormKey = "image";
|
const string fileFormKey = "image";
|
||||||
const string fileName = "image";
|
const string fileName = "image";
|
||||||
const string fileMimeType = "image/png";
|
const string fileMimeType = "image/png";
|
||||||
|
|||||||
+4
-2
@@ -691,11 +691,13 @@ speechSynthesis.getVoices();
|
|||||||
if (
|
if (
|
||||||
ref.$isVRCPlus &&
|
ref.$isVRCPlus &&
|
||||||
ref.badges &&
|
ref.badges &&
|
||||||
ref.badges.every((x) => x.badgeName !== 'Supporter')
|
ref.badges.every(
|
||||||
|
(x) => x.badgeId !== 'bdg_754f9935-0f97-49d8-b857-95afb9b673fa'
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
// I doubt this will last long
|
// I doubt this will last long
|
||||||
ref.badges.unshift({
|
ref.badges.unshift({
|
||||||
badgeId: 'bdg_system_supporter',
|
badgeId: 'bdg_754f9935-0f97-49d8-b857-95afb9b673fa',
|
||||||
badgeName: 'Supporter',
|
badgeName: 'Supporter',
|
||||||
badgeDescription: 'Supports VRChat through VRC+',
|
badgeDescription: 'Supports VRChat through VRC+',
|
||||||
badgeImageUrl:
|
badgeImageUrl:
|
||||||
|
|||||||
Reference in New Issue
Block a user