Creating an image Mask

  1. 3 months ago

    Emile S

    May 11 Europe (France, Strasbourg)
    Edited 3 months ago

    I want to create an image mask with these constraint: every white pixel in the original image have to be black.

    All I get is black, full black.

    This means that I really scan the whole original image, but inside the two For …/… Next loops, my If <Pixel -Color> Then bloack is wrong.

    To be sure, I added a Listbox and report there the x,y and color values…

         // Report the actual x,y and pixel colors
          The_Color = Outline_RGBSurf.Pixel(loop_Hor,loop_Vert)
          LB.AddRow Str(loop_Hor) + "," + Str(loop_Vert), The_Color

    loop_Hor and loop_Vert are… Horizontal and Vertical values used to scan the original image.

    Ideas ?

  2. Jeff T

    May 11 Pre-Release Testers Midlands of England, Europe

    Maybe this will do it:

    Dim map(255) As Integer
    For i As Integer = 0 To 254
      map(i) = 255
    map(255) = 0
  3. Emile S

    May 11 Europe (France, Strasbourg)

    Thank you Jeff.

    In fact, my code works fine (!), but because I do not hide the original image / revert the display, I could not saw it. Read below.

    Here is the used code:

      For loop_Vert = 0 to y
        For loop_Hor = 0 to x
          Pix_Col = Outline_RGBSurf.Pixel(loop_Hor,loop_Vert)
          If Pix_Col = RGB(255,255,255) Then // or If Pix_Col <> RGB(255,255,255) Then … *
            Temp_Pict.RGBSurface.Pixel(loop_Hor,loop_Vert) = RGB(0,0,0)
          End If
          // // Report the actual x,y and pixel colors in a Listbox (LB)
          // The_Color = Pix_Col // The_Color is a Variant
          // LB.AddRow Str(loop_Hor) + "," + Str(loop_Vert), The_Color
      cGraphics.Backdrop = Temp_Pict

    * = / <> makes two different images: the mask to the logo as black, the whole image as black excepted the logo as white !

    My error: I inverted the layers (Graphics / Backdrop) and not set it back, thus a wrong display. In Window1.MouseDown, I set the original image displayed in .Graphics to Nil to be able to see what I draw in the two loops above.

    That is part 1 of what I want to do: I want to draw an outline (black dots around what is not white in the loaded image).

    I had the code (working) in my mind since a week or so and today seems to be the good day to check it :(
    Now, I have to think to “how to make the artwork outline”.

or Sign Up to reply!