|
|
how to get the color of a pixel of an image in a pictureBox
Regards
Ramy
|
|
|
|
|
picturebox.Image.GetPixel should do it. But, if you really want to do anything with an image, you should draw it yourself, not use a picture box.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This should do it:
Dim x As Integer = Me.PictureBox1.PointToClient(Windows.Forms.Cursor.Position).X
Dim y As Integer = Me.PictureBox1.PointToClient(Windows.Forms.Cursor.Position).Y
Dim col As Color = Img.GetPixel(x, y)
And please do not double post, at least, not until your post has gone to the next page, it's really annoying and hardly anyone had had a chance to answer your old one.
Posted by The ANZAC
|
|
|
|
|
hi
i have developed crstal report thro' VB. i want to print conditional headings & details
e.g. i have 2 manufacturing plants - Inline,Online
but my report is same for both plant but having 2 different headings & no. of machines in details. i have created such scrap database file according to the requiremets
for online heading is - "Rejection analysis for" - "Online"
for inline - "Rejection analysis for" - "Inline"
M/c no. for online - 1 2 3 4
M/c no. for inline -11 12 13
could it possible using formula field ? if possible the how ?
regads
reply immediate
thanks
|
|
|
|
|
I want format of date like dd/mm/yyyy in vb.net
& how will i get only separate time at that instant
reply immediate if possible
thanks
|
|
|
|
|
msgbox(now.tostring("dd/MM/yyyy"))
msgbox(now.tostring("hh:mm:ss"))
|
|
|
|
|
Hi EveryOne,
Guys I need to deploy a .net2005 project that includes crystal reporting of .net also. I need to know which neccessary files required to be added in .net setup project coz setup project picks only CrystalDecision. CrystalReports. Design.dll. Also guide me one more thing that Is Crystal Report setup for .net 2005 is also required to be run with setup coz another application of VB 6.0 running on same PC that is using Crystal Reports 9.0
Kindly give me any idea regarding these problems.
Regards
Ali Raza
|
|
|
|
|
Hello
how to retrieve the color of a pixel in a image inserted in a picturebox
I know that :
dim img1 as bitmap
(img1.GetPixel(e.Location.X, e.Location.Y).R
but im not able to use it within the Picturebox image
Regards
Ramy
|
|
|
|
|
Get the reference of the image from the control, cast it to Bitmap and use the GetPixel method.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: Get the reference of the image from the control, cast it to Bitmap and use the GetPixel method.
get u give me an example plz
Regards
Ramy
|
|
|
|
|
charchabil03 wrote:
get u give me an example plz
If you don't understand what I suggested, just say so. Then I can explain exactly what it is that you don't get.
If you don't tell me anything about why you think that an example would help, I can't write an example that would demonstrate what it is that you have problems with. What I suggested is really simple, and I could write the single line of code that does it, but if you don't understand anything about what I suggested, what do you think that you would understand from the code?
---
single minded; short sighted; long gone;
|
|
|
|
|
This should do it:
Dim x As Integer = Me.PictureBox1.PointToClient(Windows.Forms.Cursor.Position).X
Dim y As Integer = Me.PictureBox1.PointToClient(Windows.Forms.Cursor.Position).Y
Dim col As Color = Img.GetPixel(x, y)
Posted by The ANZAC
|
|
|
|
|
Hi,
I need to store the font in db and when get back again reflect the same font from DB.
For this I have used FontDialog to set font, How do I store it in DB and get back to set in the text box when needed?
Thanks in Advance.
Be simple and Be sample.
|
|
|
|
|
You can't store a Font object in a database. You have to save the properties of the Font you want, like FontFamily as a String, Size, Height, ..., enough information to recreate the font object when you read the data back from the database.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How to use a AddressOf a Function with long type in an API. VB.Net return this error :"'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.". There are API and Function in under:
Public Declare Function EnumResourceNames Lib "kernel32" Alias "EnumResourceNamesA" (ByVal ghmodule As Long, ByVal lpType As ResType, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
------------------------------------------------------------------------------
Public Function EnumResNameProc(ByVal ghmodule As Long, ByVal lpszType As ResType, ByVal lpszName As Long, ByVal lParam As Long) As Long
Dim sNumber As String, IsNum As Boolean
If (lpszName > &HFFFF&) Or (lpszName < 0) Then
sNumber = PtrToVBString(lpszName)
IsNum = False
Else
sNumber = CStr(lpszName)
IsNum = True
End If
' 16x16
arIcon(SIZE_16, COLOR_4) = 296
arIcon(SIZE_16, COLOR_16) = 1384
arIcon(SIZE_16, COLOR_24) = 872
arIcon(SIZE_16, COLOR_32) = 1128
' 24x24
arIcon(SIZE_24, COLOR_4) = 488
arIcon(SIZE_24, COLOR_16) = 1736
arIcon(SIZE_24, COLOR_24) = 1864
arIcon(SIZE_24, COLOR_32) = 2440
' 32x32
arIcon(SIZE_32, COLOR_4) = 744
arIcon(SIZE_32, COLOR_16) = 2216
arIcon(SIZE_32, COLOR_24) = 3240
arIcon(SIZE_32, COLOR_32) = 4264
' 48x48
arIcon(SIZE_48, COLOR_4) = 1640
arIcon(SIZE_48, COLOR_16) = 3752
arIcon(SIZE_48, COLOR_24) = 7336
arIcon(SIZE_48, COLOR_32) = 9640
If IsNum Then
If lpszType = ResType.RT_ICON Then
LoadIconRes(lpszType, sNumber, giSize, giColorDepth)
End If
End If
EnumResNameProc = 1
End Function
Private Function PtrToVBString(ByVal lpszBuffer As Long) As String
Dim Buffer As String, LenBuffer As Long
LenBuffer = StrLen(lpszBuffer)
Buffer = String.Equals(LenBuffer + 1, 0)
StrCpy(Buffer, lpszBuffer)
PtrToVBString = Left(Buffer, LenBuffer)
End Function
------------------------------------------------------------------------------
For tRes = ResType.RT_FIRST To ResType.RT_LAST
Application.DoEvents()
EnumResourceNames(ghmodule, tRes, AddressOf EnumResNameProc, 0)
Next
Please help me!
|
|
|
|
|
You're trying to use old VB6 code in VB.NET. As you found out, you can't do that without some translation. You can't pass a pointer to a function under the .NET CLR like you could in the VB6 runtime. Since an object running under the .NET Framework can be moved at any time, a normal address passed to unmanaged code doesn't have any meaning.
You can find an example using the function you're looking at on P/Invoke[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I am having two controls in my form, I want to know programatically whether this control is set with BringToFront or not?
How do i get the value of controls BringToFront property value?
Rams.
Be simple and Be sample.
|
|
|
|
|
You can't because BrginToFront is not a property, it's a method. There's no value to get.
BringToFront just changes the Z-Order of the control and brings it to the top of the stack of drawn controls. There's also SendToBack which forces the conrol to the bottom of the Z-Order, making it drawn under all other controls in the collection.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello Guys,
I am trying to mark locations on a map (x,y pixels are derived from a DB)
This is the code that i am using
Private Sub DisplayOnSoftMap()<br />
SqlQuey = "Select * FROM SoftwareMap WHERE SoftwareMap.SMSID =myRndTrip.CurrentSwitch.SID & "'"<br />
tmpSoftMapCol = tmpSoftMapCol.GetAllSoftwareMap(SqlQuey)<br />
For Each tmpSoftMap In tmpSoftMapCol<br />
<br />
DrowLabel(tmpSoftMap.XMap, tmpSoftMap.YMap, tmpSoftMap.LablName)<br />
<br />
next<br />
<br />
Private Sub DrowLabel(ByVal X As Long, ByVal Y As Long, ByVal lblText As String)<br />
<br />
Dim LIndex, Lcount As Integer<br />
Try<br />
If Lbl Is Nothing Then<br />
ReDim Preserve Lbl(0)<br />
Lcount = 1<br />
LIndex = 0<br />
Else<br />
Lcount = Lbl.Length<br />
ReDim Preserve Lbl(Lcount)<br />
LIndex = Lcount<br />
End If<br />
Lbl(LIndex) = New LinkLabel<br />
Control.CheckForIllegalCrossThreadCalls = False<br />
Lbl(LIndex).Location = New System.Drawing.Point(X, Y)<br />
Lbl(LIndex).Text = lblText<br />
<br />
Lbl(LIndex).Visible = True<br />
Lbl(LIndex).AutoSize = True<br />
Control.CheckForIllegalCrossThreadCalls = False<br />
Me.Controls.Add(Lbl(LIndex))<br />
AddHandler Lbl(LIndex).Click, AddressOf Label_Click<br />
Catch ex As Exception<br />
Throw ex<br />
End Try<br />
End Sub
And this is the Error that Occurs
System.ArgumentException was caught
Message="Controls created on one thread cannot be parented to a control on a different thread."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.Form.ControlCollection.Add(Control value)
at RoundTrip.frmRoundTrip.DrowLabel(Int64 X, Int64 Y, String lblText)
--
The purpose of this code is to mark locations on a map,
I would be glad: if you help me finding the solution or any other solution which fits my needs
Regards
Ramy
|
|
|
|
|
Setting 'CheckForIllegalCrossThreadCalls' to false won't help you in this case. I tried it myself and I get the same error you do. You could do that way if you were changing the text of a control or something like that, but I don't think you should use that method in any circumstances. I don't know that for sure but I would guess not using that method is the recommended way to go. Here is a procedure you can call to safely add a control to the collection of another from any thread.
Delegate Sub AddControlDelegate(ByVal parent As Control, ByVal child As Control)
'Safely adds any control to the collection of another
'parent: The control that is the container
'child: The control to add
Private Sub AddControl(ByVal parent As Control, ByVal child As Control)
If parent.InvokeRequired Then
parent.Invoke(New AddControlDelegate(AddressOf AddControl), New Object() {parent, child})
Else
parent.Controls.Add(child)
End If
End Sub
Now when you want to add your label you just use this procedure to safely do it from any thread you wish.
AddControl(me,lbl(Lindex)) For a more in depth tutorial on updating the UI from secondary threads you should read this article http://msdn.microsoft.com/msdnmag/issues/04/05/BasicInstincts/default.aspx[^] and/or search the web. For the moment though you just need to know my procedure works
-- modified at 4:38 Saturday 17th February, 2007
|
|
|
|
|
|
Below my DropDownList bound with a Department table.Following Output iam getting,IT,CSE,Mech-these all from table.but i want an "ALL" text also there in list box..How come this possible?
Sub bindDtgrid()<br />
With dtgEmplList<br />
.DataSource = myDataSet<br />
.DataMember = myDataSet.Tables(0).TableName<br />
.DataBind()<br />
End With<br />
End Sub
Praveen.K
System Engineer
Graviton Technologies Pvt.Ltd
|
|
|
|
|
Hi
Please advise me how to enter a new row in Microsoft Access Database by using vb.net.
regards
adil
|
|
|
|
|
R u kidding asking such a question in this forum...You shud first search that into google or any other search engine, then try it yourself and if you are facing any problem then post it here so that we can help you out. We are not here for spoon feeding. please avoid such stuff in future.
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|