Why Is It That The Cint() Is Only Used For Pic.GetPixel(X,Y).R) And Not For The Others
Jul 22, 2011
i need some help on explaining to me whats going on in the code below. Basically, the code below is used to convert a bitmap image to grayscale level (black and white).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pic As Bitmap
pic = picVisible.Image
Dim X As Integer
[code].....
what i dont understand is the part;
color = (CInt(pic.GetPixel(X, Y).R) + pic.GetPixel(X, Y).G + pic.GetPixel(X, Y).B) / 3
why is it that the Cint() is only used for pic.GetPixel(X,Y).R) and not for the others ? Any Image processing expert that can help explain this ?
Note: The code works well and manages to convert an image into its grayscale.
View 2 Replies
ADVERTISEMENT
Mar 26, 2011
Many times i was not getting correct output,then i put .tostring() at the end then it gave good output.so basically why do v need this?also Convert.ToInt32(cmd.ExecuteScalar()) why convert to int32?
View 1 Replies
Jun 3, 2009
I must not be using the proper search terms.
Convert.ToInt32 obviously is a 32 Bit Integer
Convert.ToInt16 obviously is a 16 Bit Integer
So what Size does the CInt convert to?
View 5 Replies
Oct 7, 2011
I'm quite a newbie in VB.NET (and VB on the whole). So my question could sound rather odd, but still. I've stumbled upon an issue with the CInt and converting a double to an integer.
The issue is the following: CInt(10.5) would be 10
CInt(10.51) would be 11, but I expected 10... (Got used to C# style conversion: (int)10.51 would be 10)
As pointed out here Integer.Parse VS. CInt the result is just rounded in some fashion. Nowever, all I need is to get only integer part and throw away the fractional one. How can I achieve such type of conversion in VB.NET? After a short research I assume that I can use Fix() funciton to do the trick, but is it the best choice ever?
View 2 Replies
Apr 24, 2009
I have a strange problem where CInt (as well as Convert.ToInt32 or even Val) return -1 for a string "500". Using Gurock's SmartInspect for logging, I've checked all values at runtime (SiAuto... logs something, I'm posting the log below the code).
[Code]...
View 2 Replies
Aug 6, 2009
I'm having trouble getting the pixels of a Picturebox. My code is as follows:
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.Runtime.InteropServices
[Code]...
The program is supposed to load a picture, and then get each every pixel on the first line, adding the HEX color code and a "," to the richtextbox. At the last pixel of each line, it adds a ";" and skips to the next line, repeating the process until all processes are read. I've done this successfully by creating a new bitmap and using the .GetPixel from that, but that is terribly slow. Will this be faster? If not, is there any other API I could use that is faster?
View 11 Replies
Nov 28, 2010
Look at this code, it's so simple, yet I can't manage to get it to workon the top of form1 is
Option Strict On
Imports System.Drawing
Imports System.Drawing.Drawing2D
[code].....
View 5 Replies
May 18, 2010
My program works through each cell in a raster bitmap loooking at the r g b values. Actually I'm just working with greyscale so r = g = b. I use the get pixel method to return the 8 bit value of each pixel (0 - 255). However I'm now working with a single channel 32 bit float bitmap. I can't load it into VB. I tried Dim myBitmap As New Bitmap(OpenFileDialog1.FileName) but this fails with an unspecified error when trying to open a 32 bit tiff.
The question is: which graphics format will allow me to load a 32bit bitmap into VB, and if I succeed will the getpixel method return 32bit float results for the greyscale level for each pixel?
View 14 Replies
May 18, 2010
I have a icon maker program. I have two pictureboxes pic1 and pic2 and a open image button. I need a code that will if the pic1.image color has any red in it, it will take that red and turn it into the desired color. I know you can use getpixel and setpixel but I don't know how to use these.
View 13 Replies
Feb 28, 2012
Is it possible to use GetPixel in a different way? I want to use it like:
'If GetPixel(x,y) = COLOR Then
Loop Until GetPixel(x,y) = DIFFERENT COLOR
Something like that...
View 3 Replies
May 23, 2012
I worked in a role and functioning properly. The problem is that it is a bit slow for use in many images would be very slow. I read online that with stride and scan0 and working in memory with buffer can be made faster, but i donīt understand anything . Does anyone know how it works or how to make my code run faster?
[Code]...
View 12 Replies
Apr 17, 2009
i am working on a project in vb.net 2003 and i want to get the color of a pixel when i click on the image loaded in the picturebox.i ve tried anything but nothing seems to work....
View 15 Replies
Apr 24, 2010
What I'm trying to do is iterate through each pixel in a bitmap, and get the color value of each pixel.I've tried using .getpixel, but it's fairly slow. On a 640x480 image, it takes roughly .35 seconds to go through it. Which can add up if doing many pictures.
[Code]...
View 3 Replies
Mar 3, 2012
[code]Well, the first GetPixel works fine, it sets textbox2 to yellow if the pixel is ofund and textbox1 says green. But, the second GetPixel doesn't work. The coordinate are correct and the color is also, but I never receive the msgbox.
View 28 Replies
May 30, 2012
Which would be better to use if I want to find one pixel?
View 2 Replies
Mar 13, 2009
Im trying to make a program that will automatically send a left mouse click on the current mouse position using a getpixel trigger. The one i made will wait for the pixel color to change and it will trigger the next timer to monitor if an indicator hits the middle of the bar.
This is the example of the bar waiting for a color change:
This is the example of the bar when the indicator comes out
[Code]...
View 7 Replies
Apr 6, 2012
I have a timer that among other things, checks 5 spots on the screen for a color change. My program monitors a phone system app and checks to see if there is a new incoming phone call from any of 5 buttons. I'm using the following code based on another question I had posted. Monitor an area of the screen for a certain color in Visual Basic
Private Function CheckforCall()
Try
Dim queue1 As Integer = GetPixel(GetDC(0), 40, 573)
Dim queue2 As Integer = GetPixel(GetDC(0), 140, 573)
[code]....
Using this code, GDI Objects skyrockets very quickly and within short order, throws an OutOfMemory exception. I'm assuming I'm not releasing the DC properly, but I can't seem to find any other way to do it.
View 1 Replies
Oct 12, 2010
I'm trying to find the colors of pixels using GetPixel(x,y) with bitmaps.
I understand how to use it and it works.
When I use .ToString I get the string version of the color.
Now when I use .ToArgb I get a negative number and the colors are backwards?
16777215 should be white and 0 should be black.
This is an example of some results:
-16273900 is showing close to black and -32567 is showing close to white.
View 4 Replies
Jul 21, 2009
what i have been trying to get to work is getting a pixel from a program that is not focused (so minimized). I tried Getpixel but only got it to work when the window is active(focus). It seems it only works for active window.Then i thought making a temperately screenshot of the program and get the pixel. I came across PrintWindow. Right now im searching to make a temperately screenshot of a minimized program and read the pixels of it. So far i had no success.
View 1 Replies
Jan 6, 2011
I am trying to use GetPixel and SetPixel to copy the contents of one picture to another (I know there are other methods to do so, but there are reasons I want to try this ;D)Anyway, the pictures are .png images, so they include transparency settings.
But for some reason, it seems like when I use GetPixel & SetPixel to put one image over another, it seems the second image completely replaces the other one. I mean, it seems the transparency settings are not respected when I use GetPixel & SetPixel.Both images have the same size. Both have transparent areas.
View 1 Replies
Mar 31, 2010
I have build a DLL with COM enabled. In this DLL I have classes that did use the functions CInt, CDec and IsNumeric. If I test these classes from a .NET application then it works ok. But when I called/run these classes from a Win32 application (with COM) then I did get an "E_UNEXPECTED(0x8000FFFF)" error.After some debugging I found out that the problem would go away if I:- replaced IsNumeric with Integer.TryParse or Decimal.TryParse- replaced CInt with Integer.Parse- replaced CDec with Decimal.Parsey.
View 2 Replies
Dec 5, 2009
I get no compile/debug errors. When I opened it, and tested it on this site, it doesnt move the mouse to 255, 0, 0 (red). it moves it to 128-128-0.
Try
Dim dc As IntPtr
Dim screencolor As Integer
If myHandle <> IntPtr.Zero Then
dc = GetDC(myHandle)
Dim XPos As Integer = Cursor.Position.X
Dim YPos As Integer = Cursor.Position.Y
[Code] .....
View 25 Replies
Apr 23, 2010
I get no compile/debug errors. When I opened it, and tested it on this site, it doesnt move the mouse to 255, 0, 0 (red). it moves it to 128-128-0.
Try
Dim dc As IntPtr
Dim screencolor As Integer
If myHandle <> IntPtr.Zero Then
[code]....
View 2 Replies
Aug 20, 2010
in Directx Full Screen Game GetPixel Function Not Working (#000000)
View 2 Replies
Aug 28, 2009
how can i get the general color based on what is returned from Bitmap.GetPixel()? Like i want all shades of blue to just be blue, and so on
View 10 Replies
Jun 15, 2012
I don't want use old VB methods in my code and I m confused about what's the newest vb.NET method corresponding to the old CInt() VB method for example,
Dim n1 as Double : n1 = CInt(2.1111111) 'get only 2 without round it
Dim n2 as Double : n2 = CInt(2.7777777) 'get only 2 without round it
View 1 Replies