Creating an image Mask

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 ?

Maybe this will do it:

[code]Dim map(255) As Integer
For i As Integer = 0 To 254
map(i) = 255
Next
map(255) = 0

somePicture.RGBSurface.Transform(map)[/code]

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:

[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
 Next

Next

cGraphics.Backdrop = Temp_Pict[/code]

  • = / <> 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 :frowning:
Now, I have to think to “how to make the artwork outline”.