February 15, 200521 yr Lol, no offence taken. I know I'm not a pro programmer at all. They should call me an "averagegrammer" and not a "programmer" LOLEither way .. let me give you the relevant code and let me know if you can find where the memory leak happens:Dim objBMP As New System.Drawing.Bitmap(1024, 768) Private Sub cmdPasteImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPasteImage.Click 'pasting copied image back to the picturebox If Timer1.Enabled = True Then Timer1.Enabled = False Else Timer1.Enabled = True End If End Sub Public Sub PasteImage() 'check the data format in clipboard if its of type bitmap then proceed further If Clipboard.GetDataObject.GetDataPresent(DataFormats.Bitmap) Then 'setting clipboard data to picturebox 'ClearImage() objBMP = Clipboard.GetDataObject.GetData(DataFormats.Bitmap) End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'PictureBox1.CreateGraphics.Clear(Color.White) 'SendKeys.Send(skey) PasteImage() Test () End Sub Private Sub Test () TextBox1.Text = objBMP.GetPixel(560, 316).R TextBox2.Text = objBMP.GetPixel(560, 316).G TextBox3.Text = objBMP.GetPixel(560, 316).B 'Me.BackColor = objBMP.GetPixel(temp, temp) 'PictureBox1.Image = objBMP objBMP = Nothing End Sub
February 15, 200521 yr I still get a crash after sometimes 5 minutes, sometimes 10 or more. That's rather weird I believe.It makes me wonder if for some reason it could be possible that some other program (or whatever software) makes use of the clipboard and screws up my data. I should run the software again with clipboard.exe opened up perhaps and watch what happens.On the other hand, the software is starting to perform what I want it to."if pixel R value > 100 then text="AP = on else text="AP = off"All this works. So I can indeed read pixels from the panels and determine when its color changes.
February 16, 200521 yr >"No flame war" is a good idea, so just face the facts:>VB.net is written in C (or was it c++ :s not sure) so it can't>be as fastSorry, but this can't be considered an argument (nor a fact!)The compiler of a language need to be created out of another high level language for simplicity. But the code the -compiler- creates has nothing to do with the language it was programmed with, but mostly with the intelligence of its programmers and of course the language capabilities/limitations.C++ programms and VB and Pascal (and so on) programs when compiled get "translated" to (mostly) machine opcodes, that is the native code the computer understands, what assembly programs create too. If a compiler is smart enough to create quick opcode then the program will be fast. The language the compiler was created with will only affect its speed to create the executable.Why the VB.net programs are as fast as C++ ones?Because the compilers create code that uses the .net platform routines. So, there is no difference in writting a C++ loop or a VB loop. The code that will handle it will be the same.This of course is (as I said before) true for the VB.net platform only.>My suggestion is to dig up the vars of FS (or the prog you're>aiming at) from your RAM>A little research on google will learn you a lotHave you done it? It is not as easy as it looks. Most variables get created and destroyed on program execution, so one would have to trace the program execution routines and get the variables out of the stack. If you have found a better solution, please contact me privately to discuss it.
February 16, 200521 yr You could try using the windows API to handle all graphics. It is much faster. This way you could also skip copying the image inside your program. Plus, I don't think that you need to check all 3 RGB values. Just the difference in R would give you an indication of a red message and G for a green one.Lastly, it is overkill to capture a 1024, 768 bitmap (1024*768*3*16=36MB!) each time. Use the API to get only the pixel (or a limited area) directly out the window.A downside I can think is that this will only work with FS in windowed mode. In fullscreen it is all handled by directx video and most capturing will not work (I think).
February 16, 200521 yr >Sounds wonderfull .. how do I "use the windows API" ?RTM or... read the manual!If you have MSDN then it will most propably include info about it, else you can do it in the online MSDN version (from ms).Also there is a utility called ApiViewer 2004 that is of great help. Most examples are in C, but remember that a variable pointer in VB is passed by reference (byref keyword) and a variable's content by value (byval keyword).I'm no API expert to bitmap handling, but I have used it in the past for simple tasks and it is very fast.
February 16, 200521 yr I'll see what I can find.I have already a function to call the displays height & width so that I don't have to go 1024*768 if the res is lower.
February 17, 200521 yr I started in HTML, learned ASP VB from lots of different sites on the net, learned some JAVA for applets from a few books I've read, and started learning VB6 programming by using it at college for fun. At college, I was studying Aerospace Engineering and needed to take a course with C commandline stuff, I read a few chapters and completed the course in the first 3 weeks and spent the next 15 weeks classes in my dorm room teaching my roomates how to finish the class.I found some tutorials on the net for OpenGL/C++ programming as the gauges I was making for my cockpit needed to run as, obviously, they need to run as fast as possible. Using tutorials and familiarity with any programming language (especially VB), you can make the connections between the different languages.Certain elements are different (I used to use arrays and Split heaviliy in VB6, but there is no default counterpart in VB6, but upon searching, there was a class available for C++ that could split a string into a vector (kinda like an array).I am loading a few files (one of them is around 3MB and another around 2MB in file size). For me, the VB program is loading it better as translating the loading function to C++ wasnt easy and I'm having to redo the whole function over again.If you're interested in learning (and have a good pillow to place between your head and the table in front of you), the basic logic of a program are the same, but its how you go from one point to another that makes the languages different. Aaron
Create an account or sign in to comment