Results 1 to 5 of 5

Thread: Working with pictures

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Working with pictures

    I have many pictures in grey. I want to be able to turn them to black & white pictures(no grey, just black & white). My ideia is that any color that is more near to black would turn black, and any color that is more near of white would turn white. Now I don't have any kind of clue of which classes to look for in GDI+. Anyone can point me a finger here?
    \m/\m/

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Working with pictures

    Something like this:

    VB Code:
    1. Dim objImage As Bitmap
    2.         objImage = New Bitmap("C:\Temp\Test.jpg")
    3.         Dim i As Integer
    4.         Dim j As Integer
    5.  
    6.         Dim objOutput As New Bitmap(objImage.Width, objImage.Height, Imaging.PixelFormat.Format24bppRgb)
    7.         For i = 0 To objImage.Width - 1
    8.             For j = 0 To objImage.Height - 1
    9.                 'Since it is grayscale all 3 RGB values are the same, so we just check one
    10.                 If objImage.GetPixel(i, j).R < 128 Then
    11.                     objOutput.SetPixel(i, j, Color.Black)
    12.                 Else
    13.                     objOutput.SetPixel(i, j, Color.White)
    14.                 End If
    15.             Next
    16.         Next
    17.  
    18.         objOutput.Save("C:\Temp\Output.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    19.         MsgBox("Done")

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Re: Working with pictures

    That's what I thought at first, but that way surely would take many time for each image(well..actually the pictures are just 20x20) but they are A LOT and I'll have to be continuosly doing the process. I thought maybe there would be something along the matrixcolor classes or something that would be faster.

    But if there's not, then thanks by the code
    \m/\m/

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Working with pictures

    Have you seen this link:

    http://www.bobpowell.net/onebit.htm

    Looks like his way is very similar to mine.

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Re: Working with pictures

    I'm actually having problems puting the code to work as it seems I can't do SetPixel with the format of the picture I'm using.

    Additional information: SetPixel is not supported for images with indexed pixel formats.How can I convert the pixel format to an affordable one?
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width