Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Graphics : Copy part of the screen to memory

Graphics : Copy part of the screen to memory

Discuss PocketC for CE (including Desktop Edition)

Postby Xavier on Mon Dec 23, 2002 12:02 pm

How can we copy a portion ofthe screen to memory ?

The purpose is to copy a chunck of pixel from the screen to memory so as to retreive it after have drawn over it a bitmap or whatever drawing

Any Help will be appreciated.

Xavier
Xavier
 
Posts: 5
Joined: Mon Dec 23, 2002 11:59 am

Postby guy on Mon Dec 23, 2002 8:07 pm

Create a memory device context to hold your memory copy, then BitBlt() from the screen device context to the memory device context.

Look at the CreateCompatibleDC()function and the BitBlt() function.

You get the screen device context by calling GetDC() for the main window handle.

You get the main window handle by calling gethwnd(1) at the start of your program. Store the result in a global.



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Xavier on Tue Dec 24, 2002 6:28 am

OK, thanks for reply. Here is my code (but it doesn't work) :

#include "/pocketc/wingdi.h"
main ()
{
int hBm;
HWND hWnd;
HDC hdcScreen;
HDC hdcComp;
HBITMAP hbmScreen;
hWnd = gethwnd(1) ;
hdcScreen = GetDC(hWnd) ;
hdcComp = CreateCompatibleDC(hdcScreen) ;
hbmScreen = CreateCompatibleBitmap(hdcScreen,640,480);
//Capture of the screen
BitBlt(hdcComp, 0,0,640, 480, hdcScreen, 0, 0,0) ;
alert("Capture is done");
//Restoration of the screen to check if it works:
BitBlt(hdcScreen, 0,0,640, 480, hdcComp, 0, 0,0) ;
}
The last Bibblt() doesn't restore the capture on the screen. It just file it of black pixels, like if the capture screwed up.

Where is my error ?
Xavier
 
Posts: 5
Joined: Mon Dec 23, 2002 11:59 am

Postby guy on Wed Dec 25, 2002 4:47 pm

As a first step, check the return value from the BitBlt(). Then call GetLastError() to find out the error number if any problem.

The file winerror.h that is provided with ceapi lists the error message for each error number.

You need to select the compatible bitmap into the compatible device context to set its size.

Just call SelectObject(hdcComp, hbmScreen)

This should change your memory device context from one that is one bit in size into one that has the same format as the screen.

The last parameter of your BitBlt looks wrong. It should be <b>SRCCOPY</b> which is defined in wingdi.h as 0x00CC0020

Finally, is your screen on the 720 640*480, or 640*240 like on my 620?

So try:

Code: Select all
#include "/pocketc/wingdi.h"
main ()
{
int hBm;
HWND hWnd;
HDC hdcScreen;
HDC hdcComp;
HBITMAP hbmScreen;
hWnd = gethwnd(1) ;
hdcScreen = GetDC(hWnd) ;
hdcComp = CreateCompatibleDC(hdcScreen) ;
hbmScreen = CreateCompatibleBitmap(hdcScreen,640,240);
SelectObject(hdcComp, hbmScreen) ;
//Capture of the screen
BitBlt(hdcComp, 0,0,640, 240, hdcScreen, 0, 0,SRCCOPY) ;
ReleaseDC(hdcScreen) ;
alert("Capture is done");
//Restoration of the screen to check if it works:
hdcScreen = GetDC(hWnd) ;
BitBlt(hdcScreen, 0,0,640, 240, hdcComp, 0, 0,SRCCOPY) ;
ReleaseDC(hdcScreen) ;
}


I can't easily test this at the moment, but give it a try.



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Xavier on Thu Dec 26, 2002 7:41 am

Guy, thanks for your reply, It works perfectly now ! :)

First, as you said, my Bitblt parameter was wrong, I actually thought that SRCCOPY was 0, and obviously, it couldn't work. As you said either, I didn't use SelectObject() function.

By the way, I wonder why the Bitblt return value is 1 ("Incorrec function"), even when it works.

Anyhow, thanks for hepling me in this routine, which is from my point of view important for screen manipulation. For the moment, it stays not easy to manipulate, at least for me !:):):)

Thanks again.
Xavier
 
Posts: 5
Joined: Mon Dec 23, 2002 11:59 am

Postby Xavier on Thu Dec 26, 2002 7:47 am

I forgot :

My screen size on the Jornada is obviously 640x240 and not 640x480, a stupid error.

:twisted:
Xavier
 
Posts: 5
Joined: Mon Dec 23, 2002 11:59 am

Postby guy on Thu Dec 26, 2002 4:49 pm

I hope the fact that I gave you the wrong parameters for ReleaseDC() didn't cause you too much of a headache. Every time I forget to put in the hWnd parameter.


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Xavier on Fri Dec 27, 2002 12:59 pm

That was fine. I found the correct syntaxe in the "wingdi.h" when I saw it didn't work on compiling the project.

:D
Xavier
 
Posts: 5
Joined: Mon Dec 23, 2002 11:59 am


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 1 guest

cron