Skip to content
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

Screenshots fail with "Cannot get raw image from device" #35

Closed
billybednar opened this issue Jun 7, 2023 · 16 comments
Closed

Screenshots fail with "Cannot get raw image from device" #35

billybednar opened this issue Jun 7, 2023 · 16 comments
Labels
bug Something isn't working

Comments

@billybednar
Copy link

Describe the bug
After upgrading to v1.11, taking a screenshot fails 100% of the time with the error "Cannot get raw image from device." This occurs for both manual and automatic captures. If OK is clicked, the program continues but no screenshot is saved. If abort is clicked, the program exits. If nothing is clicked and automatic screenshot are on, the program exits when the next attempt fails occurs.

To Reproduce

  1. Click "Take screenshot"

Screenshots
image

Version
v1.11

OS
Windows 10 Pro 22H2 (build 19045.2965), 64 bit

Additional context
Works again after reverting to 1.10.4, although in the past I've occasionally had corrupt screenshots like the one in #32.

Log file
log.txt - doesn't look like anything useful

@jessedufrene
Copy link

Same issue with me on 1.11 portable version, running Windows 11 22H2.

It also worked fine before on 1.10.4 and 1.10.3 portable versions

I even tried deleting my config and using default settings, still the same issue.

@artem78 artem78 added the bug Something isn't working label Jun 8, 2023
@artem78
Copy link
Owner

artem78 commented Jun 8, 2023

@billybednar How many displays do you have/capture from? And which resolution?

@artem78
Copy link
Owner

artem78 commented Jun 8, 2023

Show your config.ini.

Try this build. Is the problem still exists?

AutoScreenshot_v1.11-3-g7872c3e-dirty_Windows_portable.zip

@artem78
Copy link
Owner

artem78 commented Jun 8, 2023

Same issue with me

@jessedufrene Could you also attach your log?

@jessedufrene
Copy link

log.txt - i manually triggered screenshots twice. i hit ok the first time, and abort the second time.

i've got 3 displays, a total of 5760x1200

just tried the 1.11-3 build and it looks like it works fine

@billybednar
Copy link
Author

billybednar commented Jun 8, 2023

3 displays arranged with an offset. It fails when capturing from all monitors or either of the secondary monitors, but not the primary (the one in blue).

It also occurs with the default generated config.ini.

The new build fixes it.

@artem78
Copy link
Owner

artem78 commented Jun 8, 2023

Thanks for important information.

Just another check:
AutoScreenshot_v1.11-2-g6edfe70_Windows_portable.zip

Is the bug occurs in this build or not?

@billybednar
Copy link
Author

The bug is back in that build. I tried rearranging the monitors many different ways and the positions definitely have an impact on it. Unfortunately I couldn't figure out exactly what the pattern is.

While testing these, I noticed that you get an access violation when opening a portable copy if there is already an instance running out of a different location. It only happens the first time when there is no config.ini. If you try again, it will exit cleanly instead of crashing. I can make a separate bug with more details if you want.

@artem78
Copy link
Owner

artem78 commented Jun 9, 2023

Unfortunately I couldn't figure out exactly what the pattern is.

I found it. The error occurs if you have any display above or to the left of the primary one. Like in this example:

2023-06-08_215000

In this case top-left coordinate of all visible area will be negative and this cause fails after some modifications in v1.11.

For comparision in this case capturing works fine:

2023-06-08_215329

artem78 added a commit that referenced this issue Jun 9, 2023
@artem78
Copy link
Owner

artem78 commented Jun 9, 2023

In logs you send me there is negative coordinates:

[07:57:40.303] Region: l=-1680,t=-1080,r=1920,b=1080

and

[10:07:43.278] Region: l=-1920,t=0,r=3840,b=1200

@artem78
Copy link
Owner

artem78 commented Jun 9, 2023

I can make a separate bug with more details if you want.

Yes, please make separate issue report for another problem.

@billybednar
Copy link
Author

Looks like the Windows implementation of RawImage_FromDevice takes a screenshot of the entire desktop with the incorrect assumption that the upper-left corner is (0, 0) and then tries to extract the desired region from the bitmap.

@artem78
Copy link
Owner

artem78 commented Jun 20, 2023

@billybednar I thought this is TBGRABitmap.LoadFromDevice bug from external package. I don't observe this problem in Linux. In Windows BitBlt function may be used directly. I used this solution:

var
  Bitmap: TBGRABitmap;  

......

{$IfDef Windows}
  BitBlt(Bitmap.Canvas.Handle, 0, 0, ARect.Width, ARect.Height,
           ScreenDC, ARect.Left, ARect.Top, SRCCOPY);
{$EndIf}
{$IfDef Linux}
  Bitmap.LoadFromDevice(ScreenDC, ARect);
{$EndIf}

@artem78
Copy link
Owner

artem78 commented Jun 20, 2023

I think you should create issue report in Lazarus repository.

@artem78
Copy link
Owner

artem78 commented Jun 24, 2023

Fixed in v1.12. Please check.

@artem78 artem78 closed this as completed Jun 24, 2023
@circular17
Copy link

Hello. I'm popping by to notify that I've created the bug report 40857 for Lazarus. I suggest you have a look.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants