Bit operation with PixelFormat.Alpha : Bitmap « 2D Graphics « C# / C Sharp






Bit operation with PixelFormat.Alpha

     
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

using System.Text;
using System.Windows.Forms;

public class MainClass {

    public static void Main() {
        // Create two new bitmap images
        Bitmap bmp1 = new Bitmap(100, 100, PixelFormat.Format32bppArgb);
        Bitmap bmp2 = new Bitmap(100, 100, PixelFormat.Format24bppRgb);

        // Test for alpha 
        bool b1 = ((bmp1.PixelFormat & PixelFormat.Alpha) != 0);
        bool b2 = ((bmp2.PixelFormat & PixelFormat.Alpha) != 0);

        // Output results to console window
        Console.WriteLine("bmp1 has alpha?: " + b1);
        Console.WriteLine("bmp2 has alpha?: " + b2);

        // Clean up
        bmp1.Dispose();
        bmp2.Dispose();
    }
}

   
    
    
    
  








Related examples in the same category

1.Draw on an Bitmap
2.Resize the Bitmap using the lowest quality interpolation mode
3.Resize the Bitmap using the highest quality interpolation mode
4.Create Graphics object From Image
5.Bitmap.SetResolution
6.Bitmap property: Height, Physical Dimension, width, raw format and sizeBitmap property: Height, Physical Dimension, width, raw format and size
7.Create your own BitMapCreate your own BitMap
8.Draw shapes to the bitmap in memoryDraw shapes to the bitmap in memory
9.new Bitmap(bitmap, size)
10.Read Bitmap Size by using BinaryReader
11.Bitmap.HorizontalResolution
12.Use a color matrix to change the color properties of the image
13.Create a Bitmap image in memory and set its CompositingMode
14.Create a red color with an alpha component then draw a red circle to the bitmap in memory
15.Create a green color with an alpha component then draw a green rectangle to the bitmap in memory
16.write the pixel information to the console window
17.Double buffer with Bitmap
18.Draw an array of imagesDraw an array of images
19.PixelFormat.DontCare
20.Scale Bitmap By Percent
21.Draws Bitmap in a cell within a DataGridView
22.Bitmap Image Utils
23.Bitmap Operations
24.Make Bitmap from UIElement
25.Creates a new bitmap from a specific region of another bitmap
26.Allows drawing fonts with borders and auto centers the font on a bitmap.
27.Create New Bitmap From Image
28.Simple Resize Bmp
29.Create Thumbnail
30.Calculate the RBG projection
31.Make Thumb