Making black pixels transparent

Untitled

I have two images and they have the same size. Now I need to remove pixels in Image 1 which is color black in btmp

for (int c = 0; c < selFrame.Width; c++)
  for (int j = 0; j < selFrame.Height; j++)
    {

     var pixel = selFrame.GetPixel(c, j);
     var pixel2 = btmp.GetPixel(c, j);
     if (pixel2.Equals(Color.Black) || pixel2.IsEmpty)
       {
       MessageBox.Show("qwe");
       selFrame.SetPixel(c, j, Color.Transparent);
       }

    }

MessageBox doesn't show, so that means that it didn't go through the If condition.

Here is the btmp

Image 2

Rob

Because [255,0,0,0] does not equal Color.Black.

From the documentation:

For example, Black and FromArgb(0,0,0) are not considered equal, since Black is a named color and FromArgb(0,0,0) is not.

As per the advice at the above documentation, change your check to be :

if (pixel2.ToArgb() == Color.Black.ToArgb() || pixel2.IsEmpty)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

FFMPEG: Overlaying one video on another one, and making black pixels transparent

From Dev

OpenCV function to merge Mat's except for black/transparent pixels

From Dev

How to gray scale an image with transparent pixels making all of them opaque?

From Dev

Opacity and grayscale filter of background image. Making it black and white and transparent

From Dev

Opacity and grayscale filter of background image. Making it black and white and transparent

From Dev

Using OpenCV Python, How would you make all black pixels transparent, and then overlay it over original image

From Dev

Cropping transparent pixels with carrierwave

From Dev

Black background on transparent UITabBar

From Dev

Black transparent overlay on image

From Dev

Transparent view is black?

From Dev

Convert internal transparent pixels to white pixels

From Dev

Making a canvas transparent

From Dev

Making a JTextField background transparent

From Dev

Making bootstrap dropdown transparent

From Dev

Making checkbox transparent

From Dev

Java BufferedImage Not Registering Transparent Pixels?

From Dev

IOS: color only the transparent pixels

From Dev

unable to transparent pixels of a bitmap image

From Dev

Detecting if a BufferedImage contains transparent pixels

From Dev

OpenGL Stencil - Exclude transparent pixels

From Dev

unable to transparent pixels of a bitmap image

From Dev

Count the black pixels using OpenCV

From Dev

Converting black pixels to other colours

From Dev

Converting black pixels to other colours

From Dev

Count black pixels within a circle

From Dev

Wand turns transparent background to black

From Dev

imagecreatefrompng() transparent part of png is black

From Dev

Transparent AlertDialog has black background

From Dev

imagecreatefrompng() transparent part of png is black

Related Related

  1. 1

    FFMPEG: Overlaying one video on another one, and making black pixels transparent

  2. 2

    OpenCV function to merge Mat's except for black/transparent pixels

  3. 3

    How to gray scale an image with transparent pixels making all of them opaque?

  4. 4

    Opacity and grayscale filter of background image. Making it black and white and transparent

  5. 5

    Opacity and grayscale filter of background image. Making it black and white and transparent

  6. 6

    Using OpenCV Python, How would you make all black pixels transparent, and then overlay it over original image

  7. 7

    Cropping transparent pixels with carrierwave

  8. 8

    Black background on transparent UITabBar

  9. 9

    Black transparent overlay on image

  10. 10

    Transparent view is black?

  11. 11

    Convert internal transparent pixels to white pixels

  12. 12

    Making a canvas transparent

  13. 13

    Making a JTextField background transparent

  14. 14

    Making bootstrap dropdown transparent

  15. 15

    Making checkbox transparent

  16. 16

    Java BufferedImage Not Registering Transparent Pixels?

  17. 17

    IOS: color only the transparent pixels

  18. 18

    unable to transparent pixels of a bitmap image

  19. 19

    Detecting if a BufferedImage contains transparent pixels

  20. 20

    OpenGL Stencil - Exclude transparent pixels

  21. 21

    unable to transparent pixels of a bitmap image

  22. 22

    Count the black pixels using OpenCV

  23. 23

    Converting black pixels to other colours

  24. 24

    Converting black pixels to other colours

  25. 25

    Count black pixels within a circle

  26. 26

    Wand turns transparent background to black

  27. 27

    imagecreatefrompng() transparent part of png is black

  28. 28

    Transparent AlertDialog has black background

  29. 29

    imagecreatefrompng() transparent part of png is black

HotTag

Archive