Vinicius
Vinicius
CC#
Created by Vinicius on 1/6/2023 in #help
✅ Skiarsharp - Bestway to check if image is landscape or portrait mode.
Actually my problem: an image with 4000x6000 going to landscape. But image like 845x852 won't. First approach I saw is width > height = landscape. What is the best way I can check if is portrait or landscape image?
private bool TryProcessOriginalFile(string path)
{
using var stream = File.OpenRead(Path.Combine(path, "original"));
var bmpLossless = SKBitmap.Decode(stream);

if (bmpLossless == null)
{
return false;
}
//Only using it isnt trustful
if (bmpLossless.Width > bmpLossless.Height)
{
bmpLossless = RotateLandscapeToPortrait(bmpLossless);
}

var outPathJpg = Path.Combine(path, "original.jpg");
using (var outFileJpg = new FileStream(outPathJpg, FileMode.Create))
{
bmpLossless.Encode(SKEncodedImageFormat.Jpeg, 70).SaveTo(outFileJpg);
}
bmpLossless.Dispose();
return true;
}

private static SKBitmap RotateLandscapeToPortrait(SKBitmap bmpLossless)
{
var rotated = new SKBitmap(bmpLossless.Height, bmpLossless.Width);
using (var canvas = new SKCanvas(rotated))
{
canvas.Clear();
canvas.Translate(0, bmpLossless.Width);
canvas.RotateDegrees(-90);
canvas.DrawBitmap(bmpLossless, new SKPoint());
}

return rotated;
}
private bool TryProcessOriginalFile(string path)
{
using var stream = File.OpenRead(Path.Combine(path, "original"));
var bmpLossless = SKBitmap.Decode(stream);

if (bmpLossless == null)
{
return false;
}
//Only using it isnt trustful
if (bmpLossless.Width > bmpLossless.Height)
{
bmpLossless = RotateLandscapeToPortrait(bmpLossless);
}

var outPathJpg = Path.Combine(path, "original.jpg");
using (var outFileJpg = new FileStream(outPathJpg, FileMode.Create))
{
bmpLossless.Encode(SKEncodedImageFormat.Jpeg, 70).SaveTo(outFileJpg);
}
bmpLossless.Dispose();
return true;
}

private static SKBitmap RotateLandscapeToPortrait(SKBitmap bmpLossless)
{
var rotated = new SKBitmap(bmpLossless.Height, bmpLossless.Width);
using (var canvas = new SKCanvas(rotated))
{
canvas.Clear();
canvas.Translate(0, bmpLossless.Width);
canvas.RotateDegrees(-90);
canvas.DrawBitmap(bmpLossless, new SKPoint());
}

return rotated;
}
10 replies
CC#
Created by Vinicius on 12/13/2022 in #help
❔ rename tuple
public async Task<(List<SalesReportEntity>, int totalSales)> GetAllSalesReportAsync(int companyId, int? SalesPage, int? Limitpage, DateTime? StartDate, DateTime? EndDate)
{
return (sales, sales.Count());
}
obs: I cut off some lines
public async Task<(List<SalesReportEntity>, int totalSales)> GetAllSalesReportAsync(int companyId, int? SalesPage, int? Limitpage, DateTime? StartDate, DateTime? EndDate)
{
return (sales, sales.Count());
}
obs: I cut off some lines
is returning item1: [{…}] item2: 1 How can I rename it to sales and totalSales
23 replies
CC#
Created by Vinicius on 12/8/2022 in #help
❔ SKIA SHARP PROBLEM
Error:
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'buffer')
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: at SkiaSharp.SKManagedStream.OnReadManagedStream(IntPtr buffer, IntPtr size)
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: at SkiaSharp.SKManagedStream.OnRead(IntPtr buffer, IntPtr size)
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: at SkiaSharp.SKAbstractManagedStream.ReadInternal(IntPtr s, Void* context, Void* buffer, IntPtr size)
Dec 02 16:05:23 mourashop systemd[1]: shopmoura-api-app.service: Main process exited, code=killed, status=6/ABRT
Dec 02 16:05:23 mourashop systemd[1]: shopmoura-api-app.service: Failed with result 'signal'.
Dec 02 16:05:33 mourashop systemd[1]: shopmoura-api-app.service: Scheduled restart job, restart counter is at 73.
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'buffer')
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: at SkiaSharp.SKManagedStream.OnReadManagedStream(IntPtr buffer, IntPtr size)
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: at SkiaSharp.SKManagedStream.OnRead(IntPtr buffer, IntPtr size)
Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: at SkiaSharp.SKAbstractManagedStream.ReadInternal(IntPtr s, Void* context, Void* buffer, IntPtr size)
Dec 02 16:05:23 mourashop systemd[1]: shopmoura-api-app.service: Main process exited, code=killed, status=6/ABRT
Dec 02 16:05:23 mourashop systemd[1]: shopmoura-api-app.service: Failed with result 'signal'.
Dec 02 16:05:33 mourashop systemd[1]: shopmoura-api-app.service: Scheduled restart job, restart counter is at 73.
"SkiaSharp" Version="2.88.1"
12 replies
CC#
Created by Vinicius on 10/26/2022 in #help
Entity Framework - MODEL and ENTITY
Im not sure if an ENTITY (Layer responsible for bussiness logic) is necessary instead use only MODEL responsible for database representation
1 replies
CC#
Created by Vinicius on 10/24/2022 in #help
Entity Framework - Migrations Production (Postgres)
9 replies
CC#
Created by Vinicius on 10/14/2022 in #help
HttpClient DI or USING()
29 replies
CC#
Created by Vinicius on 10/10/2022 in #help
List Add
5 replies