Init() public method

public Init ( ) : void
return void
コード例 #1
0
ファイル: GDIDIBSection.cs プロジェクト: Wiladams/NewTOAPIA
        protected override IntPtr CreatePixmapHandle(int width, int height, BitCount bitsperpixel)
        {
            //Orientation = orient;
            PixmapOrientation orient = PixmapOrientation.BottomToTop;

            // Create a bitmap compatible with the screen
            fBitmapInfo = new BITMAPINFO();
            fBitmapInfo.Init();


            m_BytesPerRow = GDIPixmap.GetAlignedRowStride(Width, bitsperpixel, Alignment);
            fBitmapInfo.bmiHeader.biWidth = Width;

            if (PixmapOrientation.TopToBottom == orient)
                fBitmapInfo.bmiHeader.biHeight = -Height;   // Indicates a top-to-bottom orientation
            else
                fBitmapInfo.bmiHeader.biHeight = Height;

            fBitmapInfo.bmiHeader.biPlanes = 1;
            fBitmapInfo.bmiHeader.biBitCount = (ushort)bitsperpixel;
            fBitmapInfo.bmiHeader.biSizeImage = (uint)(m_BytesPerRow * Height);
            fBitmapInfo.bmiHeader.biClrImportant = 0;
            fBitmapInfo.bmiHeader.biClrUsed = 0;
            fBitmapInfo.bmiHeader.biCompression = GDI32.BI_RGB;
            //fBitmapInfo.bmiColors = IntPtr.Zero;

            m_pixelPointer = IntPtr.Zero;

            IntPtr bitmapHandle = GDI32.CreateDIBSection(GDIContext.CreateForDefaultDisplay(),
                ref fBitmapInfo, GDI32.DIB_RGB_COLORS, ref m_pixelPointer, IntPtr.Zero, 0);

            return bitmapHandle;
        }
コード例 #2
0
ファイル: Pixel_Ext.cs プロジェクト: Wiladams/NewTOAPIA
        public static BITMAPINFO ToBitmapInfo(this PixelRectangleInfo pixmap)
        {
            BITMAPINFO bmi = new BITMAPINFO();
            bmi.Init();

            bmi.bmiHeader.biBitCount = (ushort)pixmap.BitsPerPixel;
            bmi.bmiHeader.biWidth = pixmap.Width;

            if (pixmap.Orientation == PixmapOrientation.TopToBottom)
                bmi.bmiHeader.biHeight = -pixmap.Height;
            else
                bmi.bmiHeader.biHeight = pixmap.Height;

            bmi.bmiHeader.biSizeImage = (uint)pixmap.GetImageSize();
            bmi.bmiHeader.biPlanes = 1;
            bmi.bmiHeader.biClrImportant = 0;
            bmi.bmiHeader.biClrUsed = 0;
            bmi.bmiHeader.biCompression = 0;

            return bmi;
        }
コード例 #3
0
ファイル: PixelBuffer.cs プロジェクト: Wiladams/NewTOAPIA
    public PixelBuffer(int width, int height)
    {
        // Create a MemoryDC to hold the bitmap.  Use IntPtr.Zero 
        // to create a device context that is compatible with the screen.
        
        fMemoryDC = GDI32.CreateCompatibleDC(IntPtr.Zero);


        // Create a bitmap compatible with the screen
        fBitmapInfo = new BITMAPINFO();
        fBitmapInfo.Init();


        fBitmapInfo.bmiHeader.biWidth = width;
        fBitmapInfo.bmiHeader.biHeight = -height;
        fBitmapInfo.bmiHeader.biPlanes = 1;
        fBitmapInfo.bmiHeader.biBitCount = 32;
        fBitmapInfo.bmiHeader.biClrImportant = 0;
        fBitmapInfo.bmiHeader.biClrUsed = 0;
        fBitmapInfo.bmiHeader.biCompression = GDI32.BI_RGB;
        fBitmapInfo.bmiColors = IntPtr.Zero;
        
        fBitmapHandle = GDI32.CreateDIBSection(User32.GetDC(IntPtr.Zero),
            ref fBitmapInfo, GDI32.DIB_RGB_COLORS, ref fBits, IntPtr.Zero, 0);

        fPixelData = new PixelData(width, height, 32, width * 4, fBits);

        // Get the bitmap structure back out so we can 
        // get our hands on the created pointer and whatnot
        //GDI32.GetBitmap(fBitmapHandle, ref fBitmapStructure);
        //fBits = fBitmapStructure.bmBits;

        // Select the bitmap into the memoryDC
        fOldBitmapHandle = GDI32.SelectObject(fMemoryDC, fBitmapHandle);
        fAlpha = 255;
    }
コード例 #4
0
ファイル: VfwCameraDevice.cs プロジェクト: Wiladams/NewTOAPIA
        void ConfigureVideoFormat()
        {
            fBitmapInfo = new BITMAPINFO();
            fBitmapInfo.Init();

            fBitmapInfo.bmiHeader = new BITMAPINFOHEADER();
            fBitmapInfo.bmiHeader.Init();

            // Get the current format information
            int formatSize = capGetVideoFormatSize();
            capGetVideoFormat(ref fBitmapInfo);

            PrintCompressionType(fBitmapInfo.bmiHeader.biCompression);

            // Fill in the things we want to change
            fBitmapInfo.bmiHeader.biWidth = Width;
            fBitmapInfo.bmiHeader.biHeight = Height;
            fBitmapInfo.bmiHeader.biPlanes = 1;
            fBitmapInfo.bmiHeader.biBitCount = 24; // 24 bits per frame - RGB
            fBitmapInfo.bmiHeader.biCompression = GDI32.BI_RGB;

            // Try to set the video format
            bool setSuccess = capSetVideoFormat(ref fBitmapInfo);

            // Get the settings again, and set the width
            // and height based on what was actually set
            capGetVideoFormat(ref fBitmapInfo);
            Width = fBitmapInfo.bmiHeader.biWidth;
            Height = fBitmapInfo.bmiHeader.biHeight;
        }
コード例 #5
0
        public virtual int PixelBlt(Rectangle srcRect, Rectangle dstRect, IntPtr pixelPtr, BitCount bitsPerPixel)
        {

            BITMAPINFO bmInfo = new BITMAPINFO();
            bmInfo.Init();
            bmInfo.bmiHeader.biWidth = srcRect.Width;
            bmInfo.bmiHeader.biHeight = srcRect.Height;
            bmInfo.bmiHeader.biPlanes = 1;
            bmInfo.bmiHeader.biBitCount = (ushort)bitsPerPixel;
            bmInfo.bmiHeader.biClrImportant = 0;
            bmInfo.bmiHeader.biClrUsed = 0;
            bmInfo.bmiHeader.biCompression = GDI32.BI_RGB;
            //bmInfo.bmiColors = IntPtr.Zero;

            int rowsWritten = GDI32.StretchDIBits(this,
                dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height,
                srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
                pixelPtr,
                ref bmInfo,
                GDI32.DIB_RGB_COLORS,
                (uint)TernaryRasterOps.SRCCOPY);

            return rowsWritten;
        }
コード例 #6
0
ファイル: GDIRenderer.cs プロジェクト: Wiladams/NewTOAPIA
        // Generalized bit block transfer
        // Can transfer from any device context to this one.
        public virtual void PixBlt(IPixelArray pixmap, int x, int y)
        {
            if (null == pixmap)
                return;

            BITMAPINFO bmi = new BITMAPINFO();
            bmi.Init();
            
            bmi.bmiHeader.biBitCount = (ushort)pixmap.BitsPerPixel;
            bmi.bmiHeader.biWidth = pixmap.Width;

            if (pixmap.Orientation == PixmapOrientation.TopToBottom)
                bmi.bmiHeader.biHeight = -pixmap.Height;
            else
                bmi.bmiHeader.biHeight = pixmap.Height;

            bmi.bmiHeader.biSizeImage = (uint)(pixmap.BytesPerRow * pixmap.Height);
            bmi.bmiHeader.biPlanes = 1;
            bmi.bmiHeader.biClrImportant = 0;
            bmi.bmiHeader.biClrUsed = 0;
            bmi.bmiHeader.biCompression = 0;

            int result = GDI32.StretchDIBits(DeviceContext, x, y, pixmap.Width, pixmap.Height, 0, 0, pixmap.Width, pixmap.Height, pixmap.Pixels,
                ref bmi, GDI32.DIB_RGB_COLORS, (uint)TernaryRasterOps.SRCCOPY);

            //Console.WriteLine("Result: {0}", result);
        }