borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Problems with MSN Api)Next Topic (System-wide hooks for Audio?) New Topic New Poll Post Reply
AndreaVB Forum : API : Graphics
Poster Message
smm
Level: Trainee

Registered: 29-07-2005
Posts: 2

icon Graphics

I have loaded graphic in picturebox and extracted the nos. of pixels throgh the GetPixel API. However, the sum of individual pixel value do not match the total pixel value.
e.g. The total pixel count for a Black & White Picture say is z. Suppose, x & y are pixel counts for VBBlack and VBWhite respectively.  x & Y do not add upto z. x+y<>z.

Pls. throw some light.  

29-07-2005 at 09:51 AM
View Profile Send Email to User Show All Posts | Quote Reply
Asim-GDI GURU
Level: Sage

Registered: 29-07-2005
Posts: 54
icon Re: Graphics

Can you please describe a little clearly what you wanna do actually.Its something very hard to understand what you wanna say...

Regards,
ASim siddiqui.

29-07-2005 at 03:08 PM
View Profile Send Email to User Show All Posts | Quote Reply
smm
Level: Trainee

Registered: 29-07-2005
Posts: 2
icon Re: Graphics


Actually I want to make microstructure analyaer. As a first step I loaded the micrograph (consisting entirely of black and white components) in the pictire box. Through the GetPixel API I found out the total pixelcount as well as the black pixel as well as the white pixels.

dim scanx, scany, pixcount as long
dim pixb,pixw as long

for scanx=0 to picture1.scalewidth-1
for scany=0 to picture1.scaleheight-1
   pixcount=pixcount+1
   if (getpixel(picture1.hdc,scanx,scany)=vbblack) then
   pixb=pixb+1
  end if
  
if (getpixel(picture1.hdc,scanx,scany)=vbwhite) then
   pixw=pixw+1
  end if
  
  next scany
next scanx

since the micrograph fitted exactly in the picbox,
pixcount should be equal to pixb+pixw

pixcount=pixb+pixw

But actually it is not so. Why? Kindly throw some light.

30-07-2005 at 06:06 PM
View Profile Send Email to User Show All Posts | Quote Reply
Asim-GDI GURU
Level: Sage

Registered: 29-07-2005
Posts: 54
icon Re: Graphics

Hi there,
Change this code a little bit.Use the following one:

dim scanx, scany, pixcount as long
dim pixb,pixw as long

pixcount=picture1.scalewidth*picture1.scaleheight
for scanx=0 to picture1.scalewidth
for scany=0 to picture1.scaleheight
   if GetPixel(picture1.hdc,scanx,scany) then
      pixw=pixw+1
  end if
  next scany
next scanx
pixb = pixcount-pixw

Regards,
Asim Siddiqui...

30-07-2005 at 07:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : Graphics
Previous Topic (Problems with MSN Api)Next Topic (System-wide hooks for Audio?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder