Click here to Skip to main content
15,887,812 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Create Image from Panel Control Pin
drago1128-Sep-14 21:13
drago1128-Sep-14 21:13 
GeneralRe: Create Image from Panel Control Pin
gwittlock29-Sep-14 3:21
gwittlock29-Sep-14 3:21 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen29-Sep-14 5:33
professionalEddy Vluggen29-Sep-14 5:33 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen28-Sep-14 22:12
professionalEddy Vluggen28-Sep-14 22:12 
GeneralRe: Create Image from Panel Control Pin
gwittlock29-Sep-14 3:19
gwittlock29-Sep-14 3:19 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen29-Sep-14 5:32
professionalEddy Vluggen29-Sep-14 5:32 
GeneralRe: Create Image from Panel Control Pin
gwittlock29-Sep-14 6:15
gwittlock29-Sep-14 6:15 
GeneralRe: Create Image from Panel Control Pin
gwittlock30-Sep-14 20:17
gwittlock30-Sep-14 20:17 
I am using the this sub and on the following line of code I get an error
VB
pixColor = myBitmap.GetPixel(x, y)


the error states "An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Drawing.dll

Additional information: Parameter must be positive and < Width."

Would anyone know why?

VB
Private Sub my_capture(ctrl As Control, fileName As String)
       Dim bounds As Rectangle = ctrl.Bounds
       Dim pt As Point = ctrl.PointToScreen(bounds.Location)
       Dim myBitmap As New Bitmap(bounds.Width, bounds.Height)
       Dim BW_Bitmap As New Bitmap(bounds.Width, bounds.Height)
       Dim x As Integer
       Dim y As Integer
       Dim pixColor As Color
       Dim luma As Integer

       Using m_g As Graphics = Graphics.FromImage(myBitmap)

           m_g.CopyFromScreen(New Point(pt.X - ctrl.Location.X, pt.Y - ctrl.Location.Y), Point.Empty, bounds.Size)

           m_g.Dispose()

       End Using

       For y = 0 To BW_Bitmap.Height

           For x = 0 To BW_Bitmap.Width

               pixColor = myBitmap.GetPixel(x, y)

               luma = CInt(pixColor.R * 0.3 + pixColor.G * 0.59 + pixColor.B * 0.11)

               BW_Bitmap.SetPixel(x, y, Color.FromArgb(luma, luma, luma))

           Next

       Next

       BW_Bitmap.Save(fileName, ImageFormat.Png)

       BW_Bitmap.Dispose()

       myBitmap.Dispose()

   End Sub

GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen5-Oct-14 2:13
professionalEddy Vluggen5-Oct-14 2:13 
GeneralRe: Create Image from Panel Control Pin
gwittlock5-Oct-14 3:16
gwittlock5-Oct-14 3:16 
Questionvb Pin
Nishat Anwar27-Sep-14 6:41
Nishat Anwar27-Sep-14 6:41 
AnswerRe: vb Pin
Dave Kreskowiak27-Sep-14 6:47
mveDave Kreskowiak27-Sep-14 6:47 
QuestionRecommendations on VB.Net to C# code conversion tool Pin
Vipul Mehta26-Sep-14 10:28
Vipul Mehta26-Sep-14 10:28 
AnswerRe: Recommendations on VB.Net to C# code conversion tool Pin
Tim Carmichael26-Sep-14 11:24
Tim Carmichael26-Sep-14 11:24 
GeneralRe: Recommendations on VB.Net to C# code conversion tool Pin
Vipul Mehta27-Sep-14 3:21
Vipul Mehta27-Sep-14 3:21 
QuestionFormatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Member 1111259726-Sep-14 7:29
Member 1111259726-Sep-14 7:29 
AnswerRe: Formatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Chris Quinn28-Sep-14 21:15
Chris Quinn28-Sep-14 21:15 
GeneralRe: Formatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Member 1111259729-Sep-14 7:10
Member 1111259729-Sep-14 7:10 
Questionicacls vbscript - disabling inheritance and removing permissions a security group Pin
Chris Cooper26-Sep-14 3:17
Chris Cooper26-Sep-14 3:17 
AnswerRe: icacls vbscript - disabling inheritance and removing permissions a security group Pin
Eddy Vluggen26-Sep-14 6:03
professionalEddy Vluggen26-Sep-14 6:03 
QuestionPloting xy grapgh on VB Pin
Member 1051522523-Sep-14 20:31
professionalMember 1051522523-Sep-14 20:31 
QuestionMore than 1 barcode reader in one pc Pin
Member 380289623-Sep-14 19:19
Member 380289623-Sep-14 19:19 
AnswerRe: More than 1 barcode reader in one pc Pin
Bernhard Hiller23-Sep-14 22:01
Bernhard Hiller23-Sep-14 22:01 
AnswerRe: More than 1 barcode reader in one pc Pin
Tino Fourie24-Sep-14 6:40
Tino Fourie24-Sep-14 6:40 
AnswerRe: More than 1 barcode reader in one pc Pin
ZurdoDev24-Sep-14 10:07
professionalZurdoDev24-Sep-14 10:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.