The buffer length X does not match the expected buffer length for a picture of width W, height H and pixel depth D
seltix5 opened this issue · 2 comments
Hello,
I was working with nuget SharpAdbClient 2.2.41 without any problem and now after updating to current version (dowloaded master) I cant get screenshots.
Code:
System.Threading.Tasks.Task<Image> task = client.GetFrameBufferAsync(device, CancellationToken.None);
Error:
The buffer length 1048576 does not match the expected buffer length for a picture of width 640, height 360 and pixel depth 32
madb/SharpAdbClient/FramebufferHeader.cs
Lines 193 to 194 in 22e9125
(Using MEmu with android 5.1.1)
Any ideas?
Thanks!
After analyzing the old version I found the problem.
On the old version, this code :
madb/SharpAdbClient/Framebuffer.cs
Lines 117 to 123 in 22e9125
was like just this:
this.Data = new byte[this.Header.Size];
and the corresponding dispose code did not exist either :
madb/SharpAdbClient/Framebuffer.cs
Lines 152 to 155 in 22e9125
The problem here, I believe, its because the pool is no more created for the requested size, when the above buffer size check is done it may fail because the current buffer size can be bigger than the necessary since its now a pool and not a fixed array anymore.
What would be the best solution for this problem?
here is what I did to fix those problems : SharpAdb/AdvancedSharpAdbClient#3 (comment)