1. How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 22, 2013
- 1572 views
For example, I read rectangle of width 4 and height 3 pixels. All of pixels are black, except one, which is white (0xFFFFFF). So, the function must produce:
{ {0, 0, 0, 0}, {0, 0, 16777215, 0}, {0, 0, 0, 0} }
2. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by BRyan Jun 22, 2013
- 1635 views
For example, I read rectangle of width 4 and height 3 pixels. All of pixels are black, except one, which is white (0xFFFFFF). So, the function must produce:
{ {0, 0, 0, 0}, {0, 0, 16777215, 0}, {0, 0, 0, 0} }
Which operating system ? Windows, Linux, Dos, OSX ? Which version of Euphoria ? ver 311, ver 4xx, ver 64bit Eu ? What video mode ? Are you asking to access the hardware directly ? You need to describe your question with more details.
3. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 22, 2013
- 1557 views
Which operating system ?
Windows XP 32-bit.
Which version of Euphoria ?
Latest 32-bit.
What video mode ?
1600x900
Are you asking to access the hardware directly ?
I am versed not well. I suppose it does not matter to me. I do not need extreme performance, if you meant it.
4. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by BRyan Jun 22, 2013
- 1584 views
Using OS XP does not allow direct access to pixels.
You can use XP Virtual DOS MACHINE but EU no longer supports DOS.
You also could emulate what ever you are trying do.
You will have to download Eu4 and try the demos and experiment.
Sorry I can't help you, maybe someone else on the forum can help you.
5. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by useless_ Jun 22, 2013
- 1600 views
Use Eu to open the image into a memory location, as a ordinary bitmap, then look at it directly using peek(). You can blit it to the screen or not, that's not necessary to read the pixels.
useless
6. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 22, 2013
- 1593 views
I want to READ pixels from screen, not read it from bmp-file and WRITE to screen! There are a lot of programs that do screenshots. Is it really impossible to do by Euphoria?
7. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by jimcbrown (admin) Jun 22, 2013
- 1543 views
I want to READ pixels from screen, not read it from bmp-file and WRITE to screen! There are a lot of programs that do screenshots. Is it really impossible to do by Euphoria?
It can be done in Euphoria. Someone wrote a program to do it as far back as 1998! http://www.RapidEuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=scapture.zip
Another example on how to do this is here: http://www.RapidEuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=color.zip http://www.RapidEuphoria.com/color.zip - look at the procedure called update_magnifier in color.exw (this first grabs a screenshot, then magnifies it).
8. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by gbonvehi Jun 22, 2013
- 1512 views
If it can be done in other languages, it can be done in Euphoria. Really, the underlying system (win32 api) is the same for all languages. Here's a quick example: http://openeuphoria.org/pastey/220.wc
9. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by petelomax Jun 22, 2013
- 1508 views
Many years ago I wrote a minesweeper beater, but I no longer have the source. There is however one in the archive by Daniel Kluss http://www.rapideuphoria.com/player2.exw which might be worth a look.
Pete
10. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 22, 2013
- 1564 views
It can be done in Euphoria. Someone wrote a program to do it as far back as 1998! http://www.RapidEuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=scapture.zip
The requested URL /scapture.zip was not found on this server.
Another example on how to do this is here: http://www.RapidEuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=color.zip http://www.RapidEuphoria.com/color.zip - look at the procedure called update_magnifier in color.exw (this first grabs a screenshot, then magnifies it).
Thanks.
I realized that win-function GetDC reads the whole screen. I have not figured out yet, what is going on between GetDC and ReleaseDC.
11. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by andi49 Jun 22, 2013
- 1487 views
Hi
this copies the upper left corner from the desktop into the Window.
Terrible slow. But working ...
Andreas
include tinewg.exw Window("TestWin",-1,-1,400,400) constant picture=Control(Picture,"",0,0,200,200) constant b1=Control (Button,"Start",200,200,80,30) constant buffer=NewMB(ScreenWidth(),ScreenHeight()) atom pix procedure copy () CaptureControl(0,buffer) -- This takes a Snapshot of the Desktop for x=0 to 200 do for y=0 to 200 do SetDrawingControl(buffer) -- Copy the pixel directly from the desktop -- is possibel but far to slow pix=GetPixelColor(x,y) SetDrawingControl(picture) -- The PictureControl in the Window SetPenColor(pix) DrawPoint(x,y) end for end for end procedure SetHandler (b1 , Click,routine_id("copy")) WinMain()
12. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 22, 2013
- 1461 views
I looked for information on the functions GetDC and GetColor. It turned out that I stated the problem incorrectly. On another forum I was advised to make a screenshot of the entire screen, then read the desired pixels from array. How to do so in Euphoria? I not understand, what is Device Contest. How to use it?
13. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by jimcbrown (admin) Jun 22, 2013
- 1478 views
I looked for information on the functions GetDC and GetColor.
It turned out that I stated the problem incorrectly. On another forum I was advised to make a screenshot of the entire screen, then read the desired pixels from array.
GetDC is the correct function to do this.
You can BitBlt from the value returned by GetDC to a screen buffer created by CreateCompatibleDC - color.exw does this. You should be able to read the values from there.
How to do so in Euphoria? I not understand, what is Device Contest. How to use it?
gbonvehi's example shows how to use this quite well, imho. He copies the pixels one by one instead of copying it to an array, but otherwise does what you ask... it should be simple to modify his example to, for example, save the screenshot into an image file on disk instead of copying the screenshot to another window.
14. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by gbonvehi Jun 22, 2013
- 1436 views
I created a new example buffering into a Pixmap which makes it tolerable to test copying 600x400 pixel by pixel: http://openeuphoria.org/pastey/221.wc
Edit: Instead of copying the desktop to an array, I create a copy in a pixmap (a kind of invisible bitmap), once you get to that point, you can use and manipulate the pixmap as needed. I this case, I copy it to the window on each paint event pixel by pixel, this is just an example, you should use bitblt or other copy image operation for performance.
15. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 23, 2013
- 1471 views
GetDC is the correct function to do this.
You can BitBlt from the value returned by GetDC to a screen buffer created by CreateCompatibleDC - color.exw does this. You should be able to read the values from there.
I think there are too many intermediate transformations. Is it possible to copy the data from the Device Context directly to the sequence? I assume that this will turn out a one-dimensional array, where the pixels are following each other. May be, with some trash data (BMP header?). I would arrange it.
16. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by jimcbrown (admin) Jun 23, 2013
- 1457 views
GetDC is the correct function to do this.
You can BitBlt from the value returned by GetDC to a screen buffer created by CreateCompatibleDC - color.exw does this. You should be able to read the values from there.
I think there are too many intermediate transformations. Is it possible to copy the data from the Device Context directly to the sequence? I assume that this will turn out a one-dimensional array, where the pixels are following each other. May be, with some trash data (BMP header?). I would arrange it.
What will you do with the sequence once you have it?
17. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 23, 2013
- 1409 views
What will you do with the sequence once you have it?
Why do you want to know this? I'm not going to write it in any file, nor on the screen, if you are worried about it.
18. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by useless_ Jun 23, 2013
- 1401 views
What will you do with the sequence once you have it?
Why do you want to know this? I'm not going to write it in any file, nor on the screen, if you are worried about it.
Because it might be handy for visual object recognition, for non-contact measuring, for motion detection, etc.. Sheesh, get paranoid already!
useless
19. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by jimcbrown (admin) Jun 23, 2013
- 1375 views
What will you do with the sequence once you have it?
Why do you want to know this? I'm not going to write it in any file, nor on the screen, if you are worried about it.
Well, despite all the solutions you've been given, you keep asking questions about how to do this. And what you're asking for seems to change slightly each time.
There's nothing wrong with trying to fine tune it like this, but we might be able to give you a quicker, more accurate answer if we better understood what you were trying to do.
20. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 23, 2013
- 1383 views
Well, despite all the solutions you've been given, you keep asking questions about how to do this. And what you're asking for seems to change slightly each time.
I admit that formulated the problem incorrectly. This is due to the fact that I'm not familiar with the technical side of the issue. However, the main point remains the same as in my first message. I want to be able to read pixel color in a specific location on the screen. I think you can read the pixels one by one. It turned out that it is necessary to read all at once to the array, and then read the one by one from the array. Only the result is important.
There's nothing wrong with trying to fine tune it like this, but we might be able to give you a quicker, more accurate answer if we better understood what you were trying to do.
OK. Now that I know about this a bit more, I can articulate exactly. I need a function, that make the screenshot and produce sequence of pixels' colors. It does not matter whether it is a one-dimensional or two-dimensional array. No matter what the form will be submitted to the pixel colors - RGB, CMYK... A redundant information (BMP header of something similar) may be present in this sequence. I want to extract the color of certain pixel from this sequence.
21. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by jimcbrown (admin) Jun 23, 2013
- 1375 views
It turned out that it is necessary to read all at once to the array, and then read the one by one from the array.
Why?
OK. Now that I know about this a bit more, I can articulate exactly. I need a function, that make the screenshot and produce sequence of pixels' colors.
The code from gbonvehi can do that already: http://openeuphoria.org/pastey/221.wc#0
You just need to modify CopyFromPixmapToWindowPixelByPixel so it saves the rgb into a sequence instead of copying it into a window.
I want to extract the color of certain pixel from this sequence.
Which pixel? Are you looking for a certain color amoung the pixels, or trying to determine what colors a specific group of pixels are? What's the end purpose here?
22. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by DerekParnell (admin) Jun 23, 2013
- 1340 views
For example, I read rectangle of width 4 and height 3 pixels. All of pixels are black, except one, which is white (0xFFFFFF). So, the function must produce:
{ {0, 0, 0, 0}, {0, 0, 16777215, 0}, {0, 0, 0, 0} }
I understand your request, but it to avoid some ambiguity, and avoiding giving you an answer on how to do it the 'hard way', may I ask for some clarifications, please.
Firstly, I can see by the responses so far, that you are working in the Windows environment. So with that in mind, when you say "screen" do you really mean "window" or are you referring to the literal screen itself. And if so, will you need a solution that works in multi-monitor scenarios?
Now about the actual problem you are trying to solve. How will knowing the colors of a set of "screen" pixels help you with your program's task? I ask this, because your request is fairly unusual in a Windowed environment. Mainly because the pixels of a specific screen location give no indication of what application drew those pixels in the first place - it can be any window that the user just happened to move there or it could just be the user's choice of background photo (or whatever).
I guess to better help you achieve your program's aim, it might be good if we understood the 'requirement' to read pixels at a specific screen location. Can you fill us in on that a bit more, please.
Anyhow, reading pixels from a specific location of a Window, it pretty easy, if you know which window you are targeting.
23. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by TheresNoTime Jun 24, 2013
- 1332 views
Sorry, the issue is off the agenda.
24. Re: How to read rectangular part of screen, pixel-by-pixel?
- Posted by useless_ Jun 24, 2013
- 1310 views
That was like watching a slow motion train wreck get hit by a third train.
useless