|
mimi8469 wrote: PLS I NEED HELP.. AM DESPERATE..
No, you're not. You're not even interested. I tried all day to get you to answer me so I could help you, and you couldn't be bothered. I assume as your deadline gets closer, you'll post again, but if you care enough to post, I can only assume you can't understand what we're telling you, so your best bet is to approach the teacher to discuss if you're smart enough for a programming course.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I wonder how s/he accepts such projects without knowing a thing about what s/he is actually trying to do. What is more funnier is that s/he is worried about reaching deadlines too.
|
|
|
|
|
Hi
I'm trying to read a selected pixel color of another application but having some difficulties. Here's the code:
<br />
Public Sub GetNewPicture(ByVal hwnd As IntPtr, ByVal WindowWidth As Integer, ByVal WindowHeight As Integer)<br />
<br />
Dim b As Bitmap<br />
Dim gfx As Graphics = Graphics.FromHwnd(hwnd)<br />
<br />
b = New Bitmap(WindowWidth, WindowHeight, gfx)<br />
<br />
MsgBox(b.GetPixel(5, 5).R)<br />
<br />
End Sub<br />
The b.getpixel(5,5).R always return 0. I use this approach because I don't want too use the standard GetPixel Api because it's way too slow. But I can't get this to work. Help is really apprechiated.
EDIT: Forgot to tell you that I want to read the pixel color of the program even if it's not the top-most window (Hidden by another window). Would this ever be possible or is it impossible?
|
|
|
|
|
Member 4368316 wrote: I use this approach because I don't want too use the standard GetPixel Api because it's way too slow
Well, this is dumb. You're STILL calling GetPixel, you're just creating an entire bitmap first. You think that will be faster ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yeah you'r correct, but I won't use the code I wrote before like that. I'm going to take the "sceenshot" of the application and then from a separat function get the pixels (at least that's the idea). It's alot faster (in my Opinion) if you need to read many pixels. Here's another code I used before to get pixels (which is faster than calling the GetPixel Api directly). But it's limited to only the visible windows. I want to get the pixels even if the window is invisible (behind another window and not necessary minimized).
<br />
Private b as bitmap<br />
<br />
Public Sub Screenshot()<br />
<br />
b = New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height,Imaging.PixelFormat.Format32bppArgb)<br />
<br />
Dim gfx As Graphics = Graphics.FromImage(b)<br />
<br />
gfx.CopyFromScreen(My.Computer.Screen.Bounds.X, My.Computer.Screen.Bounds.Y, 0, 0,Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)<br />
<br />
End sub<br />
<br />
public function GetPixel(byval x as integer, byval y as integer)<br />
<br />
return b.GetPixel(x, y).R<br />
<br />
End Sub<br />
modified on Tuesday, November 10, 2009 3:41 PM
|
|
|
|
|
Member 4368316 wrote: It's alot faster (in my Opinion) if you need to read many pixels
Calling GetPixel, is faster than calling GetPixel ? Really ?
You should read my image processing articles to find out how to actually look pixels up quickly.
Member 4368316 wrote: But it's limited to only the visible windows. I want to get the pixels even if the window is invisible (behind another window and not necessary minimized).
The pixels don't exist, how can you get them ? If you have a handle to the window, and it's a .NET object, you can call DrawToBitmap, otherwise, you can't read a pixel that does not exist.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Sorry for the confusion I didn't mean the call to GetPixel is faster, I meant it's faster to use the GetPixel if you have the source in memory and getting all the pixel directly from memory (When I think about it shouldn't all pixel information be in memory?). Well I'm starting to get confused, I try to find your article Christian Graus maybe things will clear up for me . Am I wrong when I think I see a speed improvement with the code in my second post. If you would compare it with the createDC("DISPLAY",0,0,0) combined with the GetPixel way?
Christian Graus wrote: The pixels don't exist, how can you get them ? If you have a handle to the window, and it's a .NET object, you can call DrawToBitmap, otherwise, you can't read a pixel that does not exist.
Okey that's bad news I just thought it was possible because I think I remember a while ago I saw an article about hooking a program that was minimized to get it's pixels. And by that I thought the pixel information must be stored somewhere even when the window isn't visible.
Edit: I have read some of your article Christian Graus (Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^]) is your way (LockBits) the fastest or is BitBlit faster?
Edit2: I think I have found a article that has the solution I'm looking for. http://www.fengyuan.com/article/wmprint.html
modified on Tuesday, November 10, 2009 5:33 PM
|
|
|
|
|
Member 4368316 wrote: is your way (LockBits) the fastest or is BitBlit faster?
They do different things. LockBits locks the bits to view them. BitBlt is how C++ draws an image. In C++, if an image is a DIBSection, you get a pointer and can access the data, just like you can with LockBits, so I assume a GDI+ bitmap is always a DIBSection. This makes it possible that GetPixel is faster in C# than in C++, but you at a minimum still pay the cost of a method call.
I don't believe you can use pointers in VB, you may need to write this part in a C# dll to use my code.
Feng Yuan is a very cool guy, his book on C++ Graphics programming is the best one I've ever bought. The code you're linking to is in C++, you realise that, right ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: Feng Yuan is a very cool guy, his book on C++ Graphics programming is the best one I've ever bought. The code you're linking to is in C++, you realise that, right ?
Hehe yea I know, I just linked to show that there is a workaround (for future readers). The only question now is if there's any possibility to implement that into vb or if I should modify his program instead. I haven't read the article yet so I will start off with that first
Thanks for your help Christian Graus.
|
|
|
|
|
You should be able to use p/invoke to call C APIs in VB.
Good luck.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: Feng Yuan is a very cool guy, his book on C++ Graphics programming is the best one I've ever bought.
Sorry to nag you Christian, but would you have a link to where I can purchase it, I'm in the market for a good c++ book (ship to canada = gold), and again only if you have a url handy..
|
|
|
|
|
suppose in a string var ="abc" values i want that Keyboard automatically type this string in TextBox
plz tell me how its possible
|
|
|
|
|
Don't cross post.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Your question seems a little confused.
To put the value of the variable var into a textbox programatically just set the text property e,g, myTextbox.Text = var .
If your question is about sending keypresses to another application outside of your control you can use the SendMessage[^] API to programatically do anything to any identified window. That is not simple though.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
I am creating a program in VB.net (VS2005)
I want to know that how to dispose all objects used in my program while closing the program.
Thanks.
Gagan
|
|
|
|
|
You enumerate through your objects and call Dispose on them.
Seriously, your question about shutting down is not answerable because we have no idea what your code is doing, how the app is written, what your code does in the event of a shutdown request, ...
What is the main purpose of the app and how is the engine that provides this functionality written??
|
|
|
|
|
Some objects have a .Dispose method which you can call.
Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced.
For example:
myObj.dispose() ' only if supported
myObj = nothing ' indicate that the object is no longer referenced
|
|
|
|
|
David Mujica wrote: Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced.
that is completely irrelevant when the app is about to shut down as the OP stated.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
When an app shuts down, the Operating System recovers memory allotted to that app. So you don't have to worry about it. Modern operating systems (including Windows) are pre-emptive, i.e., they don't need the permission or co-operation of the applications to recover memory.
|
|
|
|
|
Also, all .Net finalizers are run while the application shuts down.
|
|
|
|
|
Not necessarily. The runtime host can decide whether to run finalizers or not during application shutdown.
|
|
|
|
|
Hi all...
I have created a program that checks system's processor's ID and some registry keys before starting. After that it works in background.
The problem is here that when the program is in execution and I am trying to shutdown my system then my system is not shutting down and the problem is that Windows is unable to kill my program's execution forcefully or something like that. How to solve this problem, suggest me.
Thanks.
Gagan
|
|
|
|
|
did you do anything special to get that?
is your app windowless?
maybe SystemEvents.SessionEnding could help you out.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Well, I am getting processor's ID by importing System.management namespace and bye creating objects of ManagementObject and ManagementObjectSearcher and getting registry keys by using my.computer.registry class.
Could you explain me your solution or do you have any piece of code?
Thanks.
Gagan
|
|
|
|
|
use Google to research; you might find things like this[^].
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|