Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Mike Gagnon
  Where is Mike Gagnon?
 Pointe Claire
 Canada
 Mike Gagnon
 To: Emerson Reed
  Where is Emerson Reed?
 Americana - SP
 Brazil
 Emerson Reed
 Tags
Subject: RE: Remove all non black pixels from image
Thread ID: 393935 Message ID: 393982 # Views: 61 # Ratings: 1
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Friday, December 27, 2013 1:02:56 PM         
   


> ----- Updated -----
> Hi folks!
> Using GDIPlusX, how to remove all non black pixels from an image?
>
> Emerson Santon Reed
> "One Developer CAN Make a Difference. A community CAN make a future." - Craig Boyd


cImage = Getpict('jpg')
 ConvertToGrayscale(cImage)

Function ConvertToGrayscale(lcImage)
   Set Classlib To Home()+'ffc/_gdiplus.vcx' Additive
   oLogoImage = Newobject('gpBitmap',Home()+'ffc/_gdiplus.vcx')
   oLogoImage.CreateFromFile(lcImage)
   Private x,Y,nColor
   lnWidth = oLogoImage.imagewidth
   lnHeight = oLogoImage.imageheight
   For Y=0 To lnHeight-1
       For x=0 To lnwidth-1
       WAIT WINDOW NOWAIT "Largeur en pixels: "+TRANSFORM(x)+", hauteur en pixels :" +TRANSFORM(y)
         nColor = oLogoImage.GetPixel(x,Y)
         oColor = Createobject("gpColor",nColor)
       oAvg = (oColor.Red+oColor.Green+oColor.Blue)/3
       oColor.set(INT(oAvg),INT(oAvg),INT(oAvg))
          oLogoImage.SetPixel(x,Y,oColor.ARGB)
     NEXT
   NEXT
   oLogoImage.SaveToFile("c:\ex.jpg","image/jpeg", "quality=100" )
Endfunc



Mike Gagnon

ENTIRE THREAD

Remove all non black pixels from image Posted by Emerson Reed @ 12/26/2013 5:36:16 PM
RE: Remove all non black pixels from image Posted by Pete Sass @ 12/26/2013 9:29:54 PM
RE: Remove all non black pixels from image Posted by Mike Gagnon @ 12/27/2013 1:02:56 PM
RE: Remove all non black pixels from image Posted by Koen Piller @ 12/27/2013 9:19:50 PM