url = 'https://www.mathworks.com/matlabcentral/answers/492597-is-it-possible-to-take-a-screenshot-of-a-website-with-matlab';
[~, webHandle] = web(url);
pause(5);
location = webHandle.getLocationOnScreen();
rect = java.awt.Rectangle();
rect.x = location.x;
rect.y = location.y;
rect.width = webHandle.getWidth();
rect.height = webHandle.getHeight();
robot = java.awt.Robot();
capture = robot.createScreenCapture(rect);
rawData = reshape(capture.getRaster().getDataBuffer().getData(), rect.width, rect.height);
rgb = zeros(rect.height, rect.width, 3);
rgb(:, :, 1) = bitshift(bitand(rawData', hex2dec('ff0000')), -16);
rgb(:, :, 2) = bitshift(bitand(rawData', hex2dec('ff00')), -8);
rgb(:, :, 3) = bitand(rawData', hex2dec('ff'));
rgb = rgb / 255;
figure;
image(rgb);
0 Comments
Sign in to comment.