I am using jna.jar, jna-3.2.5.jar and jna-3.3.0-platform.jar in my Java project.
This is the Winapi function that I want to replicate.
BOOL WINAPI MagImageScalingCallback( _In_ HWND hwnd, _In_ void *srcdata, _In_ MAGIMAGEHEADER srcheader, _Out_ void *destdata, _In_ MAGIMAGEHEADER destheader, _In_ RECT unclipped, _In_ RECT clipped, _In_ HRGN dirty );
This is my java code
public interface MagImageScalingCallback extends StdCallLibrary.StdCallCallback{ public boolean MagImageScalingCallback(HWND hwnd, Pointer srcdata, MAGIMAGEHEADER.ByValue srcheader, Pointer destdata, MAGIMAGEHEADER.ByValue destheader, RectByValue source, RectByValue clipped, HRGN dirty); }
When I enter this callback method, I get unexpected results:
public boolean MagImageScalingCallback(HWND hwnd, Pointer srcdata, MAGIMAGEHEADER.ByValue srcheader, Pointer destdata, MAGIMAGEHEADER.ByValue destheader, RectByValue source, RectByValue clipped, HRGN dirty) { image.setRGB(0, 0, srcheader.width, srcheader.height, srcdata.getIntArray(0, srcheader.width * srcheader.height ), 0, srcheader.width); return true; }
This table explains what works and what doesn't work on 32-bit and 64-bit systems when I change the data type of variables.
+--------------+--------------+-------------+-------------+ | Parameter | Data type | 64 bit | 32 bit | +--------------+--------------+-------------+-------------+ | source | WinDef.RECT | Working | Not Working | | clipped | WinDef.RECT | Working | Not Working | | source | RectByValue | Working | Working | | source | RectByValue | Working | Working | | srcdata | Pointer | Working | Not Working | | destdata | Pointer | Working | Not Working | +--------------+--------------+-------------+-------------+
Not working means a completely black image as a result
If I use the above code on a 64-bit system, I can capture the desktop (I can access the data from a pointer variable). If I use the same code on a 32-bit system, I do not get any image. You can see all my code
Why is there an error in my code? How can i fix this?
For your information. As you see in screenSkip.java , whenever the MagSetWindowSource function is called. Called by MagImageScalingCallback (on line 80).
Problems in this section of code
If I run this code on a 64-bit system, srcdata and destdata will hold an array of integer pixels on the desktop (if I save this as an image, it captures the desktop). But if I run the same code on a 32-bit system, then both values โโof a variable pixel of a variable are always zero (if I save an image, it is always black)
64-bit system [! [enter image description here] [2]] [2]
32 bit system 
@ david-heffernan I am running this code on a 32 bit system. I know The Magnification API is not supported under WOW64; . This means that a 32-bit zoom application runs on a 32-bit system, and a 64-bit zoom application runs on a 64-bit system. Please stop commenting that the zoom API is not working on WOW64 and is trying to execute this code on a 32-bit system.
As for your request, the figure below shows the configuration of my system.
