Skip to content

Epson.PrintImage taking a lot of time #293

@nk-alex

Description

@nk-alex

I'm using ESCPOS_NET 3.0.0 on my .NET 9.0 Maui application. Following #111 I tried to convert the given code to .NET Maui (Without using System.Drawing). I ended up with this:

IList<byte[]> data = new List<byte[]>
{
    Epson.CenterAlign()
};

byte[] logoBytes = System.Convert.FromBase64String(Helpers.Settings.Logo);
int size = 256;

SKImage image = SKImage.FromEncodedData(logoBytes);
SKBitmap imageBitmap = SKBitmap.FromImage(image);

for (int i = 0; i < Math.Round((double)image.Height / size, 0, MidpointRounding.ToPositiveInfinity); i++)
{
    int width = image.Width;
    int height = size * (i + 1) <= image.Height ? size : image.Height - (size * i);

    SKBitmap newImage = new SKBitmap(width, height);

    using (SKCanvas canvas = new SKCanvas(newImage))
    {
        canvas.DrawBitmap(imageBitmap, new SKRect(0, 0, width, height), new SKRect(0, i * size, width, height));

        using (MemoryStream memoryStream = new MemoryStream())
        {
            SKData newImageData = newImage.Encode(SKEncodedImageFormat.Webp, 10);
            newImageData.SaveTo(memoryStream);
            data.Add(Epson.PrintImage(newImageData.ToArray(), true, true, 512, 0));
        }
    }
}

return ByteSplicer.Combine(data.ToArray());

My problem is with Epson.PrintImage(newImageData.ToArray(), true, true, 512, 0) no matter the parameters I try, it takes like 10 seconds to return everytime it's called. Is there anyway to speedup this process?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions