-
-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printing Images - Height #111
Comments
Hi, sorry for the delay getting back to you. What happens if you set the width on the image and print it? Are there other too-tall images that print correctly? The reason I ask is that the bar prints the whole way down, so that makes me think the problem might be with the PNG you are using and not with the lib resizing the image. |
Hello, no problem. This was resolved by dividing the bitmap in parts of 256px of height and then printing. |
Had to do something similar, sharing for future generations... private static IEnumerable<Image<Rgba32>> ExtractChunks(Image<Rgba32> sourceImage)
{
const int chunkSize = 256;
for (var y = 0; y < sourceImage.Height; y += chunkSize)
{
Rectangle sourceArea = new(0, y, sourceImage.Width, Math.Min(sourceImage.Height - y, chunkSize));
if (sourceArea.Height < 1)
{
yield break;
}
Image<Rgba32> targetImage = new(sourceArea.Width, sourceArea.Height);
int height = sourceArea.Height;
sourceImage.ProcessPixelRows(targetImage, (sourceAccessor, targetAccessor) =>
{
for (int i = 0; i < height; i++)
{
Span<Rgba32> sourceRow = sourceAccessor.GetRowSpan(sourceArea.Y + i);
Span<Rgba32> targetRow = targetAccessor.GetRowSpan(i);
sourceRow.Slice(sourceArea.X, sourceArea.Width).CopyTo(targetRow);
}
});
yield return targetImage;
}
} |
I ended up doing solving this like this, to solve some buffer issues, and some slow image printing issues.
|
Hello, first of all, the library is incredible!! I made a question on Stackoverflow (for more details), about the height of the image when I print. I'm using Xamarin Android, I created a bitmap with SkiaSharp and save it as PNG. It's perfectly saved on my device. But when I'll print it, the necessary height to print the whole bitmap is not matching. I tried with this image, it's a logo with a width more larger than the height, 3840x2160, and it worked perfectly. And my bitmap have the height more larger than the width (it's a list), 700 of width and 1280 of height. Both images are PNG and 72 of DPI. I'm reducing the width as follows:
buffer = ByteSplicer.Combine( e.PrintImage(logo, true, true, 372, 0) );
If I don't reduce the width, it prints a lot of random characters.
The width is perfect, but I have the height similar to the first image, it seems a "logo size".
Can you show an example of how can we print images/bitmaps that have a big height like a list without cutting/limiting it?
Tests:
I Printed this PNG file:
And this is the result:
But when I print this:
That's the result:
In this test, it still shows this thing next to the sticker, but with another image that I tested, it printed the height of the sticker (same cutted as the test above) and just it.
The text was updated successfully, but these errors were encountered: