Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting pixel in JPG
Message
 
To
09/09/2005 10:52:05
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
01048135
Message ID:
01048212
Views:
19
Here is a function that converts a JPG to grayscale, pixel by pixel, the function is too slow to be used for that purpose if the image is too large, but perhaps it can help you.
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 "Width in pixels: "+TRANSFORM(x)+", Height in 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
>I know this may sound crazy but I am looking for a way to detect specific pixels in a JPG. Basically, when someone upload a new picture on UT, most of them, even if written in the technical specifications, omit to build the one pixel black border around the picture. Yes, I know. I should have avoided that since the debut and build the image in a class that would show the specific border that I would have wanted. But, I have more than a thousands built like that so we will continue to request that one pixel black border.
>
>So, is there a way to detect that from a JPG? Basically, I would have to check each pixel of the first row, each one of the right side and so on for the color 000000. Is that doable?
Previous
Reply
Map
View

Click here to load this message in the networking platform