|
This is a known problem with the Image.FromFile method:
This occurs when you set the Image property of a PictureBox control to a file manually at design time, or when you use the FromFile method at run time.
The workaround is to use the Image.FromStream method instead:
Using fs As Stream = System.IO.File.OpenRead("img-0.png")
PictureBox2.Image = Image.FromStream(fs)
End Using
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi there,
I try to use a code from your site: href="http://www.codeproject.com/Articles/617613/Fast-pixel-operations-in-NET-with-and-without-unsa
in VB.NET.
I get: a system overflow exception in my code below.
Quote: Dim diffR As Integer = CInt(pixelR - searchedR) '<=================
' pixelR is 128, searchedR is 0
I assume, that the code is correct where the exception pops up. Can you have a look at my code?
Thanks for any help
Bernd
<blockquote class="quote"><div class="op">Quote:</div>Function true_Black_and_White_Unsafe_Methode( _
MyImage As Image,
searchedR As Byte, searchedG As Byte, searchedB As Byte, _
Tolerance As Integer) As Image
' Source:
' http://www.codeproject.com/Articles/617613/Fast-pixel-operations-in-NET-with-and-without-unsa
Dim Bmp8 As New Bitmap(MyImage.Width, MyImage.Height, PixelFormat.Format1bppIndexed)
Dim imageData As BitmapData = Bmp8.LockBits(New Rectangle(0, 0, MyImage.Width, _
MyImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb)
Dim bytesPerPixel As Integer = 3
Dim scan0 As Integer = imageData.Scan0
Dim stride As Integer = imageData.Stride
Dim unmatchingValue As Byte = 0
Dim matchingValue As Byte = 255
Dim toleranceSquared As Integer = Tolerance * Tolerance
Dim y As Integer
For y = 0 To imageData.Height - 1
Dim row(scan0 + (y * stride)) As Integer
Dim x As Integer
For x = 0 To imageData.Width - 1
' Watch out for actual order (BGR)!
Dim bIndex As IntPtr = x * bytesPerPixel
Dim gIndex As IntPtr = bIndex + 1
Dim rIndex As IntPtr = bIndex + 2
Dim pixelR As Byte = row(rIndex)
Dim pixelG As Byte = row(gIndex)
Dim pixelB As Byte = row(bIndex)
' here is the system overflow exception
Dim diffR As Integer = CInt(pixelR - searchedR) '<=================
' pixelR is 128, searchedR is 0</blockquote>
Dim diffR As Integer = CInt(pixelR - searchedR) '<=================
' pixelR is 128, searchedR is 0
Dim diffG As Integer = CInt(pixelG - searchedG)
Dim diffB As Integer = CInt(pixelB - searchedB)
Dim distance As Integer = diffR * diffR + diffG * diffG + diffB * diffB
If distance > toleranceSquared Then
row(rIndex) = row(bIndex) = row(gIndex) = unmatchingValue
Else
row(rIndex) = row(bIndex) = row(gIndex) = matchingValue
End If
Next
Next
Bmp8.UnlockBits(imageData)
Return Bmp8
End Function</blockquote>
|
|
|
|
|
Articles are support by the people that write them. Articles are written by volunteers, not the staff of CodeProject.
At the bottom of the article there is a forum, just like this one. Ask your question there.
|
|
|
|
|
Good afternoon to everyone. First of all i'm sorry if my question might seem stupid but please understand me....i'm not a very practice programmer!!
THIS IS MY ACTUAL SITUATION:
In this moment i've a program (ABC) not created by me.This program expose a COM interface. This program has different function and every function is holded is a particular secondary form.
If I start a new VB.NET project and then I add a reference to the executable file of the program above (ABC) my VisualStudio imports the interop of the program. Than using the CreateObject Function I can access to some Function of the executable file. This allow me to send some string from my own program (FGH written in VB6) to the other one (ABC).
THIS SHOULD BE MY NEW SITUATION:
Now, I made a new program NEWABC(similar to the old ABC) but the form will be opened with Process.Start so instead having only one process as in ABC i will have as many processes are the Windows opened. Now, from the older FGH a from a newer NEWFGH (written in .NET) i would like to find a particular process launched by NEWABC and send him a particular string. I could do this operation using Drag&Drop but this operation is to slow because I would like that clicking a control button he made everything in 1ms.
Does anyone have some idea to recommend me?
Thany you very much
Jack
|
|
|
|
|
You can send information between .NET processes using pipes.
Since you just need to send an object to the process, you shouldn't need a named pipe.
A fair starter point is at:
https://msdn.microsoft.com/en-us/library/bb762927(v=vs.110).aspx
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Thank you very much Benjamin for your reply.
From Yesterday evening I got 2 illuminations and I found two solutions to my problem.
The first solution I found was using the 2 user32.dll function (GetForegroundWindow and GetWindowText) to retrieve the correct window i need to post message and then send the message throught the user32 function SetWindowText. In This way thorught the events TextChange of my second application I was able to get the message. But I didn't love so much this solution so i found this other one.
The second solution as been found on codeproject to this link Send strings to another application by using Windows messages[^]
I made a dll that will be imported in all my applications and in this way i'm able to get message.
I knew that throught pipe were possible to solve my problem but I afraid that my friend will not be able to use pipe in VB6 so I needed to find a solution also usable throught VB6......
|
|
|
|
|
VB6 can use named pipes. It's just not supported in anything convenient like it is in the .NET Framework. He'll just have to build his own VB6 code implementation on top of Windows function calls to make his support for it.
|
|
|
|
|
JackMisani wrote: Thank you very much Benjamin for your reply.
His name's Nathan. The bit at the bottom of the message is his "signature", which is a quote from Benjamin Disraeli[^]; he's not actually the 1st Earl of Beaconsfield.
Similarly, I am not Homer[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I was willing to let him believe that.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hi,
i wrote a small vb.net console application for sending emails to a gmail-account.
The application works fine on my developement-system ( wondows 10).
When i distribute the application to Windows server 2012 r2 the app did not send the email, the app termine without error but the email was not send.
i try allready to switch firewall off, but without success.
Anybody has a idea what can be wrong?
The code loke like this:
Imports System.IO
Imports System.Net.Mail
Imports System.Net
Sub Main()
Try
Dim loMessage As MailMessage = Nothing
Dim loClient As SmtpClient = Nothing
loClient = New SmtpClient()
loClient.Timeout = 50000
loClient.Host = "smtp.gmail.com"
loClient.Port = 587
loClient.EnableSsl = True
loClient.Credentials = New System.Net.NetworkCredential("test@gmail.com", "xxxxxxxxxx")
loMessage = New MailMessage()
loMessage.IsBodyHtml = True
loMessage.From = New MailAddress("xxxxxx@gmail.com")
loMessage.To.Add(New MailAddress("xxxxxx@bluewin.ch"))
loMessage.Subject = "Betreff"
loMessage.Body = "Test Ihre Daten..."
loClient.Send(loMessage)
Catch ex As Exception
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter("c:\tmp\err.txt", True)
file.WriteLine(ex.ToString)
file.Close()
End Try
End Sub
|
|
|
|
|
Make sure that the server anti-virus isn't implementing "mass mailing protection". I've had that problem with McAfee Enterprise.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Thanks for the hint, but i did not use mc-affee and for testing i had disabled the installed anti-virus.
|
|
|
|
|
Thanks solved!!!
modified 9-May-16 8:02am.
|
|
|
|
|
Most likely because you spelled "debug" incorrectly, one 'g' not two.
However, it appears that you are trying to mix a Windows program with a console app, and you give no clue where this message appears from.
|
|
|
|
|
HI, I tried both in ConsoleApplication and in wpf...on another pc it WORKS on wpf application...I have on mine 2010 version...the same message appears on both applications...'c\....exe is missing. Looked over all google advices I could find, tried all but nth...in wpf it does not work on my pc either..but on another it does...???(code is copy/pasted)
|
|
|
|
|
Very interesting, but it tells us nothing. You need to explain exactly what happens, where the code fails and what results or messages you see, or expect but do not see.
|
|
|
|
|
I get the message that the .exe file does not exist. Otherwise, the code should create simple xaml file.
|
|
|
|
|
Member 12473290 wrote: the message that the .exe file does not exist. Then you know what to do.
|
|
|
|
|
Please, I am complete beginner, I looked all arround google to find the answer but no success. Is there a usefull link or sth? many thanks!!!
|
|
|
|
|
The shortcut you're clicking on doesn't go anywhere. It's pointing an .EXE file that isn't there!
|
|
|
|
|
I answered this question in the very first reply to you, which you have ignored. And we still have no real idea what your problem is, apart from the fact that 'something' cannot find your program. If you do not know where it is then how do you expect a bunch of strangers to know? We have no access to your system, so cannot see your screen, or search your hard drive.
|
|
|
|
|
In future, please do not remove the original problem; a forum like this works better if it remains because someone else might come across a similar issue but because you've removed it, they might miss that you had the same thing and would thus miss the solution.
|
|
|
|
|
How to connect and open firebird 3 database with vb
Net
yung
|
|
|
|
|
|
I trying that but still cannot open connection. Can u help me mr with sample source code for every body in codeproject. Tq u very much mr
yung
|
|
|
|