コード例 #1
0
        // Display fingerprint image on screen
        public IPictureDisp PrintBiometricDisplay(bool isBiometric, GrFingerXLib.GRConstants contextId)
        {
            // handle to finger image
            IPictureDisp handle = null;
            // screen HDC
            IntPtr hdc = GetDC(System.IntPtr.Zero);

            if (isBiometric)
            {
                // get image with biometric info
                axGrFingerXCtrl.BiometricDisplay(ref FPTemplate.ImageData,
                                                 ref RawFPImg.Image, RawFPImg.Width, RawFPImg.Height, RawFPImg.Resolution, hdc.ToInt32(),
                                                 ref handle, (int)contextId);
            }
            else
            {
                // get raw image
                axGrFingerXCtrl.CapRawImageToHandle(ref RawFPImg.Image, RawFPImg.Width,
                                                    RawFPImg.Height, hdc.ToInt32(), ref handle);

                //Consolidate();
            }

            // draw image on picture box
            if (handle != null)
            {
                return(handle);
            }

            // release screen HDC
            ReleaseDC(System.IntPtr.Zero, hdc);

            return(null);
        }
コード例 #2
0
        public unsafe void ITypeInfo_GetNames_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            BSTR *rgszNames = stackalloc BSTR[2];

            rgszNames[0] = new BSTR("Name1");
            rgszNames[1] = new BSTR("Name2");
            uint cNames = 0;

            hr = typeInfo.GetNames((DispatchID)4, rgszNames, 2u, &cNames);
            Assert.Equal(HRESULT.S_OK, hr);
            Assert.Equal("Width", rgszNames[0].String.ToString());
            Assert.Equal("Name2", rgszNames[1].String.ToString());
            Assert.Equal(1u, cNames);

            rgszNames[0].Dispose();
            rgszNames[1].Dispose();
        }
コード例 #3
0
        private void OpenButton_Click(object sender, EventArgs e)
        {
            if (((mCurrentDoc != null)))
            {
                mCurrentDoc.Close();
            }

            string filename = OpenFile();


            if ((!string.IsNullOrEmpty(filename)))
            {
                mCurrentDoc = mApprenticeServer.Open(filename);


                if ((mCurrentDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject))
                {
                    mCurrentDrawingDoc = (ApprenticeServerDrawingDocument)mCurrentDoc;
                }


                IPictureDisp oPicDisp = (IPictureDisp)mCurrentDoc.Thumbnail;
                Image        image    = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(oPicDisp);

                //image.Save("c:\Temp\Thumbnail.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

                PreviewPic.Image = image;
                PreviewPic.Refresh();

                lbFilename.Text = "File: " + mCurrentDoc.DisplayName;

                ViewerButton.Enabled = true;
            }
        }
コード例 #4
0
        public unsafe void ITypeInfo_GetContainingTypeLib_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            IntPtr typeLib = (IntPtr)int.MaxValue;
            uint   index   = uint.MaxValue;

            hr = typeInfo.GetContainingTypeLib(&typeLib, &index);
            try
            {
                Assert.Equal(HRESULT.S_OK, hr);
                Assert.NotEqual(IntPtr.Zero, typeLib);
                Assert.NotEqual(0u, index);
            }
            finally
            {
                Runtime.InteropServices.Marshal.Release(typeLib);
            }
        }
コード例 #5
0
        public unsafe void IDispatch_Invoke_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = MockAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;

            Guid    riid       = Guid.Empty;
            var     dispParams = new DISPPARAMS();
            var     varResult  = new object[1];
            var     excepInfo  = new EXCEPINFO();
            uint    argErr     = 0;
            HRESULT hr         = dispatch.Invoke(
                (DispatchID)4,
                &riid,
                Kernel32.GetThreadLocale(),
                DISPATCH.PROPERTYGET,
                &dispParams,
                varResult,
                &excepInfo,
                &argErr
                );

            Assert.Equal(HRESULT.S_OK, hr);
            Assert.Equal(16, GdiHelper.HimetricToPixelY((int)varResult[0]));
            Assert.Equal(0u, argErr);
        }
コード例 #6
0
        public static Bitmap ConvertPixelByPixel(IPictureDisp ipd)
        {
            // get the info about the HBITMAP inside the IPictureDisp
            DIBSECTION dibsection = new DIBSECTION();

            GetObjectDIBSection((IntPtr)ipd.Handle, Marshal.SizeOf(dibsection), ref dibsection);
            int width  = dibsection.dsBm.bmWidth;
            int height = dibsection.dsBm.bmHeight;

            // create the destination Bitmap object
            Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            unsafe
            {
                // get a pointer to the raw bits
                RGBQUAD *pBits = (RGBQUAD *)(void *)dibsection.dsBm.bmBits;

                // copy each pixel manually
                for (int x = 0; x < dibsection.dsBmih.biWidth; x++)
                {
                    for (int y = 0; y < dibsection.dsBmih.biHeight; y++)
                    {
                        int offset = y * dibsection.dsBmih.biWidth + x;
                        if (pBits[offset].rgbReserved != 0)
                        {
                            bitmap.SetPixel(x, y, Color.FromArgb(pBits[offset].rgbReserved, pBits[offset].rgbRed, pBits[offset].rgbGreen, pBits[offset].rgbBlue));
                        }
                    }
                }
            }

            return(bitmap);
        }
コード例 #7
0
ファイル: Images.cs プロジェクト: xxdoc/SKS
        /// <summary>
        /// Converts a IPictureDisp into a cursor.
        /// </summary>
        /// <param name="source">The source IPicture to be converted.</param>
        /// <returns>The source IPicture as a Cursor.</returns>
        public static Cursor CreateCursor(IPictureDisp source)
        {
            Cursor res;
            Image  sourceImg = null;
            Icon   vb6Icon   = null;

            try
            {
                sourceImg = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureToImage(source);
            }
            catch
            {
                try
                {
                    //In the case that the image is an Icon, this will convert it into a Bitmap
                    vb6Icon   = IPictureDispToIcon(source);
                    sourceImg = vb6Icon.ToBitmap();
                }
                catch { }
            }

            res = CreateCursor(sourceImg);

            return(res);
        }
コード例 #8
0
ファイル: MockAxHost.cs プロジェクト: tbolon/winforms
        public static Image?GetPictureFromIPictureDisp(object picture)
        {
            if (picture is null)
            {
                return(null);
            }

            int          hPal = default;
            IPictureDisp pict = (IPictureDisp)picture;
            PICTYPE      type = (PICTYPE)pict.Type;

            if (type == PICTYPE.BITMAP)
            {
                try
                {
                    hPal = pict.hPal;
                }
                catch (COMException)
                {
                }
            }

            Image?image = GetPictureFromParams(pict.Handle, type, hPal, pict.Width, pict.Height);

            GC.KeepAlive(pict);
            return(image);
        }
コード例 #9
0
        public unsafe void ITypeInfo_GetVarDesc_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            VARDESC *pVarDesc = null;

            try
            {
                hr = typeInfo.GetVarDesc(3, &pVarDesc);
                Assert.Equal(HRESULT.S_OK, hr);
                Assert.Equal((DispatchID)4, pVarDesc->memid);
                Assert.Equal(IntPtr.Zero, pVarDesc->lpstrSchema);
                Assert.Equal(IntPtr.Zero, pVarDesc->unionMember);
                Assert.Equal(VARENUM.USERDEFINED, pVarDesc->elemdescVar.tdesc.vt);
                Assert.NotEqual(IntPtr.Zero, pVarDesc->elemdescVar.tdesc.union.lpadesc);
                Assert.Equal(IntPtr.Zero, pVarDesc->elemdescVar.paramdesc.pparamdescex);
                Assert.Equal(PARAMFLAG.NONE, pVarDesc->elemdescVar.paramdesc.wParamFlags);
                Assert.Equal(VARFLAGS.FREADONLY, pVarDesc->wVarFlags);
                Assert.Equal(VARKIND.DISPATCH, pVarDesc->varkind);
            }
            finally
            {
                typeInfo.ReleaseVarDesc(pVarDesc);
            }
        }
コード例 #10
0
 /// <summary>
 /// Converts a <see cref="IPictureDisp"/> instance to an equivalent <see cref="Icon"/>  instance.
 /// </summary>
 /// <param name="pictureDisp">The <see cref="IPictureDisp"/> instance to convert.</param>
 /// <returns>A <see cref="Icon"/> instance equivalent to <paramref name="pictureDisp"/>.</returns>
 public static Icon IPictureDispToIcon(IPictureDisp pictureDisp)
 {
     using (var bitmap = new Bitmap(IPictureDispToImage(pictureDisp)))
     {
         return(Icon.FromHandle(bitmap.GetHicon()));
     }
 }
コード例 #11
0
        public unsafe void ITypeInfo_Invoke_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            var  dispParams = new DISPPARAMS();
            var  varResult  = new object[1];
            var  excepInfo  = new EXCEPINFO();
            uint argErr     = 0;

            hr = typeInfo.Invoke(
                picture,
                (DispatchID)4,
                DISPATCH.PROPERTYGET,
                &dispParams,
                varResult,
                &excepInfo,
                &argErr
                );
            Assert.Equal(HRESULT.DISP_E_MEMBERNOTFOUND, hr);
            Assert.Null(varResult[0]);
            Assert.Equal(0u, argErr);
        }
コード例 #12
0
ファイル: FormSymbolSelector.cs プロジェクト: jzChia/demo
        /// <summary>
        /// 预览选中符号,使其显示在图片控件中
        /// </summary>
        private void PreviewImage()
        {
            ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass);
            IPictureDisp         pPictureDisp         = pSymbologyStyleClass.PreviewItem(currentStyleGalleryItem, PreviewSymbology.Width, PreviewSymbology.Height);

            PreViewImage = Image.FromHbitmap(new System.IntPtr(pPictureDisp.Handle));
            PreviewSymbology.Appearance.Image = PreViewImage;
        }
コード例 #13
0
ファイル: AddScaleForm.cs プロジェクト: yanfp/Water-quality
        protected void PreviewImage()
        {
            ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);
            IPictureDisp         pPicture             = pSymbologyStyleClass.PreviewItem(m_pStyleGalleryItem, picBoxPreview.Width, picBoxPreview.Height);
            Image pImage = Image.FromHbitmap(new IntPtr(pPicture.Handle));

            picBoxPreview.Image = pImage;
        }
コード例 #14
0
        public void GetPictureFromIPictureDisp()
        {
            using Bitmap bitmap = new Bitmap(100, 200);
            IPictureDisp picture = AxHostAccess.GetIPictureDispFromPicture(bitmap);

            Assert.NotNull(picture);
            using Image image = AxHostAccess.GetPictureFromIPictureDisp(picture);
            Assert.NotNull(image);
            Assert.Equal(bitmap.Size, image.Size);
        }
コード例 #15
0
        public void IPictureDispToImageTest()
        {
            Reports_Accessor target = new Reports_Accessor(); // TODO: Initialize to an appropriate value
            IPictureDisp     img    = null;                   // TODO: Initialize to an appropriate value

            System.Drawing.Image expected = null;             // TODO: Initialize to an appropriate value
            System.Drawing.Image actual;
            actual = target.IPictureDispToImage(img);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #16
0
        public static IPictureDisp GetIPictureDispImage(Bitmap bitmap)
        {
            Bitmap newIcon = bitmap;

            newIcon.MakeTransparent();
            ImageList newImageList = new ImageList();

            newImageList.Images.Add(newIcon);
            IPictureDisp tempImage = Convert(newImageList.Images[0]);

            return(tempImage);
        }
コード例 #17
0
        public static Bitmap ConvertWithAlphaBlend(IPictureDisp ipd)
        {
            // get the info about the HBITMAP inside the IPictureDisp
            DIBSECTION dibsection = new DIBSECTION();

            GetObjectDIBSection((IntPtr)ipd.Handle, Marshal.SizeOf(dibsection), ref dibsection);
            int width  = dibsection.dsBm.bmWidth;
            int height = dibsection.dsBm.bmHeight;

            // zero out the RGB values for all pixels with A == 0
            // (AlphaBlend expects them to all be zero)
            unsafe
            {
                RGBQUAD *pBits = (RGBQUAD *)(void *)dibsection.dsBm.bmBits;

                for (int x = 0; x < dibsection.dsBmih.biWidth; x++)
                {
                    for (int y = 0; y < dibsection.dsBmih.biHeight; y++)
                    {
                        int offset = y * dibsection.dsBmih.biWidth + x;
                        if (pBits[offset].rgbReserved == 0)
                        {
                            pBits[offset].rgbRed   = 0;
                            pBits[offset].rgbGreen = 0;
                            pBits[offset].rgbBlue  = 0;
                        }
                    }
                }
            }

            // create the destination Bitmap object
            Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            // get the HDCs and select the HBITMAP
            Graphics graphics = Graphics.FromImage(bitmap);

            IntPtr hdcDest      = graphics.GetHdc();
            IntPtr hdcSrc       = CreateCompatibleDC(hdcDest);
            IntPtr hobjOriginal = SelectObject(hdcSrc, (IntPtr)ipd.Handle);

            // render the bitmap using AlphaBlend
            BLENDFUNCTION blendfunction = new BLENDFUNCTION(AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA);

            AlphaBlend(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, width, height, blendfunction);

            // clean up
            SelectObject(hdcSrc, hobjOriginal);
            DeleteDC(hdcSrc);
            graphics.ReleaseHdc(hdcDest);
            graphics.Dispose();

            return(bitmap);
        }
コード例 #18
0
        public unsafe void IDispatch_GetTypeInfoCount_Invoke_Success()
        {
            using var image = new Bitmap(16, 16);
            IPictureDisp picture  = MockAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;

            uint    ctInfo = uint.MaxValue;
            HRESULT hr     = dispatch.GetTypeInfoCount(&ctInfo);

            Assert.Equal(HRESULT.S_OK, hr);
            Assert.Equal(1u, ctInfo);
        }
コード例 #19
0
        public unsafe void IDispatch_GetTypeInfo_Invoke_Success()
        {
            using var image = new Bitmap(16, 16);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;

            ITypeInfo typeInfo;
            HRESULT   hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);
            Assert.NotNull(typeInfo);
        }
コード例 #20
0
        public void GetIPictureDispFromImage()
        {
            using Icon icon     = SystemIcons.Question;
            using Bitmap bitmap = icon.ToBitmap();
            IPictureDisp picture = AxHostAccess.GetIPictureDispFromPicture(bitmap);

            Assert.NotNull(picture);
            Assert.Equal(PICTYPE.BITMAP, (PICTYPE)picture.Type);

            Assert.Equal(bitmap.Size.Height, GdiHelper.HimetricToPixelY(picture.Height));
            Assert.Equal(bitmap.Size.Width, GdiHelper.HimetricToPixelX(picture.Width));
        }
コード例 #21
0
            public Bitmap GetImage(Size imageSize)
            {
                IPictureDisp pict = _commands._item.GetImageMso(_id, imageSize.Width, imageSize.Height);

                try
                {
                    return(ImageUtils.GetBitmapFromHBitmap(new IntPtr(pict.Handle)));
                }
                finally
                {
                    ComRelease.Release(pict);
                }
            }
コード例 #22
0
        public unsafe void IDispatch_GetTypeInfo_Invoke_Success()
        {
            using var image = new Bitmap(16, 16);
            IPictureDisp picture  = MockAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;

            ITypeInfo typeInfo;
            HRESULT   hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);
            Assert.NotNull(typeInfo);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(typeInfo);
        }
コード例 #23
0
        public unsafe void ITypeInfo_GetImplTypeFlags_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            IMPLTYPEFLAG implTypeFlags = (IMPLTYPEFLAG)(-1);

            hr = typeInfo.GetImplTypeFlags(0, &implTypeFlags);
            Assert.Equal(HRESULT.S_OK, hr);
            Assert.NotEqual(IMPLTYPEFLAG.FDEFAULT, implTypeFlags);
        }
コード例 #24
0
        public unsafe void ITypeInfo_GetMops_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, 0, out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            var mops = new string[] { "Mops" };

            hr = typeInfo.GetMops((DispatchID)4, mops);
            Assert.Equal(HRESULT.S_OK, hr);
            Assert.Equal(new string[] { null }, mops);
        }
コード例 #25
0
        public unsafe void ITypeInfo_AddressOfMember_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            IntPtr pv = (IntPtr)int.MaxValue;

            hr = typeInfo.AddressOfMember((DispatchID)6, INVOKEKIND.FUNC, &pv);
            Assert.Equal(HRESULT.TYPE_E_BADMODULEKIND, hr);
            Assert.Equal(IntPtr.Zero, pv);
        }
コード例 #26
0
        public unsafe void ITypeInfo_GetMops_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            var mops = new BSTR("Mops");

            hr = typeInfo.GetMops((DispatchID)4, &mops);
            Assert.Equal(HRESULT.S_OK, hr);
            Assert.Empty(mops.String.ToString());
        }
コード例 #27
0
        public unsafe void ITypeInfo_GetRefTypeOfImplType_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            uint refType = uint.MaxValue;

            hr = typeInfo.GetRefTypeOfImplType(0, &refType);
            Assert.Equal(HRESULT.S_OK, hr);
            Assert.NotEqual(0u, refType);
        }
コード例 #28
0
ファイル: Connect.cs プロジェクト: sharewebcode/Web
        public void OnStartupComplete(ref Array custom)
        {
            try
            {
                IPictureDisp ipd = applicationObject.CommandBars.GetImageMso("Paste", 32, 32);

                IconViewForm form = new IconViewForm();

                form.IconPictureBox.Image = IPictureDispConverter.ConvertPixelByPixel(ipd);

                form.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #29
0
        public unsafe void ITypeInfo_CreateInstance_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, Kernel32.GetThreadLocale(), out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            Guid   riid  = typeof(IPictureDisp).GUID;
            IntPtr pvObj = (IntPtr)int.MaxValue;

            hr = typeInfo.CreateInstance(IntPtr.Zero, &riid, &pvObj);
            Assert.Equal(HRESULT.TYPE_E_BADMODULEKIND, hr);
            Assert.Equal(IntPtr.Zero, pvObj);
        }
コード例 #30
0
        public unsafe void ITypeInfo_GetNames_Invoke_Success()
        {
            using var image = new Bitmap(16, 32);
            IPictureDisp picture  = SubAxHost.GetIPictureDispFromPicture(image);
            IDispatch    dispatch = (IDispatch)picture;
            ITypeInfo    typeInfo;
            HRESULT      hr = dispatch.GetTypeInfo(0, 0, out typeInfo);

            Assert.Equal(HRESULT.S_OK, hr);

            var  rgszNames = new string[2];
            uint cNames    = 0;

            hr = typeInfo.GetNames((DispatchID)4, rgszNames, (uint)rgszNames.Length, &cNames);
            Assert.Equal(HRESULT.S_OK, hr);
            Assert.Equal(new string[] { "Width", null }, rgszNames);
            Assert.Equal(1u, cNames);
        }
コード例 #31
0
ファイル: Images.cs プロジェクト: WebMAPTestUser/SKS
        /// <summary>
        /// Converts a IPictureDisp into a cursor.
        /// </summary>
        /// <param name="source">The source IPicture to be converted.</param>
        /// <returns>The source IPicture as a Cursor.</returns>
        public static Cursor CreateCursor(IPictureDisp source)
        {
            Cursor res;
            Image sourceImg = null;
            Icon vb6Icon = null;
            try
            {
                sourceImg = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureToImage(source);
            }
            catch
            {
                try
                {
                    //In the case that the image is an Icon, this will convert it into a Bitmap
                    vb6Icon = IPictureDispToIcon(source);
                    sourceImg = vb6Icon.ToBitmap();
                }
                catch { }
            }

            res = CreateCursor(sourceImg);

            return res;
        }
コード例 #32
0
 /// <summary>
 /// Reverse conversion
 /// </summary>
 /// <param name="picture"></param>
 /// <returns></returns>
 public static Image PictureDispToImage(IPictureDisp picture)
 {
     return GetPictureFromIPicture(picture);
 }
コード例 #33
0
ファイル: OutputOptions.cs プロジェクト: ORRNY66/GS
        private void DrawCurrentFrame()
        {
            int position = 0;

            // update current pts && current position
            mCurrentPTS = mConverter.AVPrope.FrameInfo.PTS;
            labelCurrentTime.Text = DurationToStr(mCurrentPTS);
            if (!mChanging && (mDuration > 0))
            {
                mChanging = true;
                try
                {
                    position = (int)Math.Round((double)trackBarPreview.Maximum * mCurrentPTS / mDuration);
                    if (position > trackBarPreview.Maximum)
                        position = trackBarPreview.Maximum;
                    trackBarPreview.Value = position;
                }
                catch
                {

                }
                finally
                {
                    mChanging = false;
                }
            }
            // copy the frame to bitmap
            SafeFreeIPictureDisp();
            mPictureDisp = mConverter.AVPrope.CurrentPicture;

            if (mPictureDisp != null)
            {
                pictureBoxPreview.BackColor = Color.Black;
                pictureBoxPreview.Image = PictureDispHost.GetPictureFromIPicture(mPictureDisp);
            }
        }
コード例 #34
0
ファイル: Images.cs プロジェクト: WebMAPTestUser/SKS
 /// <summary>
 /// Converts a IPictureDisp to Icon.
 /// </summary>
 /// <param name="iPictureDisp">The picture to be converted.</param>
 /// <returns>The source picture as an Icon.</returns>
 public static Icon IPictureDispToIcon(IPictureDisp iPictureDisp)
 {
     return Icon.FromHandle(new IntPtr(iPictureDisp.Handle));
 }
コード例 #35
0
ファイル: OutputOptions.cs プロジェクト: ORRNY66/GS
 private void SafeFreeIPictureDisp()
 {
     if (mPictureDisp != null)
     {
         mPictureDisp = null;
         GC.Collect();
     }
 }