当前位置: 首页>>代码示例>>C#>>正文


C# Image.GetType方法代码示例

本文整理汇总了C#中Image.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Image.GetType方法的具体用法?C# Image.GetType怎么用?C# Image.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadImageInformation

        private void LoadImageInformation(Image image)
        {
            if (image == null) return;

            //get native resolution information
            lblNativeResolutionInfo.Text = string.Format("{0}x{1}", image.Width, image.Height);
            //get image type
            lblImageTypeInfo.Text = image.GetType().Name;
        }
开发者ID:mrsheen,项目名称:VS2010-Image-Debugger-Visualizer,代码行数:9,代码来源:FrmImage.cs

示例2: ConvertImageToByte

        /// <summary>
        /// Converte uma imagem em array de bytes.
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public static byte[] ConvertImageToByte(Image image)
        {
            if (image == null)
                return null;

            byte[] bytes;
            if (image.GetType().ToString() == "System.Drawing.Image")
            {
                ImageConverter converter = new ImageConverter();
                bytes = (byte[])converter.ConvertTo(image, typeof(byte[]));
                return bytes;
            }
            else if (image.GetType().ToString() == "System.Drawing.Bitmap")
            {
                bytes = (byte[])TypeDescriptor.GetConverter(image).ConvertTo(image, typeof(byte[]));
                return bytes;
            }
            else
                throw new NotImplementedException("ConvertImageToByte invalid type " + image.GetType().ToString());
        }
开发者ID:renattomachado,项目名称:boletonet,代码行数:25,代码来源:Utils.cs

示例3: FromImage

        public static Graphics FromImage(Image image)
        {
            if (image == null)
                throw new ArgumentNullException ("image");

            if ((image.PixelFormat & PixelFormat.Indexed) != 0)
                throw new Exception ("Cannot create Graphics from an indexed bitmap.");

            Bitmap b = image as Bitmap;
            if (b == null)
                throw new Exception ("Can not create Graphics contexts from " + image.GetType () + " Images, only Bitmaps are supported");

            var bitmapContext = b.GetRenderableContext ();

            return new Graphics (bitmapContext, false);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:16,代码来源:Graphics.cs

示例4: UpdatePreview

        private void UpdatePreview(Image img)
        {
            if (img != null)
            {
                tsslStatusWidth.Text = $"Width: {img.Width}px";
                tsslStatusHeight.Text = $"Height: {img.Height}px";
                tsslStatusPixelFormat.Text = $"Pixel format: {img.PixelFormat}";
                tsslStatusType.Text = $"Type: {img.GetType().Name}";

                Bitmap bmpPreview = RenderPreview(img);

                SetPreviewImage(bmpPreview);
            }
        }
开发者ID:Jaex,项目名称:ImageVisualizer,代码行数:14,代码来源:ImageVisualizerForm.cs

示例5: GetInstance

 /// <summary>
 /// Gets an instance of an Image.
 /// </summary>
 /// <param name="image">an Image</param>
 /// <returns>an object of type Gif, Jpeg or Png</returns>
 public static Image GetInstance(Image image) {
     if (image == null)
         return null;
     return (Image)image.GetType().GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new Type[] {typeof(Image)}, null).Invoke(new object[] {image});
 }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:10,代码来源:Image.cs

示例6: CreateWithHttpInfo

        /// <summary>
        /// Attach a CD-ROM You can attach a CD-ROM to an existing server. You can attach up to 2 CD-ROMs to one server.
        /// </summary>
        /// <param name="datacenterId"></param> 
        /// <param name="serverId"></param> 
        /// <param name="cdrom">CD-ROM to be attached</param> 
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> 
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param> 
        /// <returns>ApiResponse of Image</returns>
        public ApiResponse<Image> CreateWithHttpInfo(string datacenterId, string serverId, Image cdrom, bool? parameter = null, int? depth = null)
        {

            // verify the required parameter 'datacenterId' is set
            if (datacenterId == null)
                throw new ApiException(400, "Missing required parameter 'datacenterId' when calling AttachedCDROMsApi->Create");

            // verify the required parameter 'serverId' is set
            if (serverId == null)
                throw new ApiException(400, "Missing required parameter 'serverId' when calling AttachedCDROMsApi->Create");

            // verify the required parameter 'cdrom' is set
            if (cdrom == null)
                throw new ApiException(400, "Missing required parameter 'cdrom' when calling AttachedCDROMsApi->Create");


            var path_ = "/datacenters/{datacenterId}/servers/{serverId}/cdroms";

            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json", "application/vnd.profitbricks.resource+json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/vnd.profitbricks.resource+json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (datacenterId != null) pathParams.Add("datacenterId", Configuration.ApiClient.ParameterToString(datacenterId)); // path parameter
            if (serverId != null) pathParams.Add("serverId", Configuration.ApiClient.ParameterToString(serverId)); // path parameter

            if (parameter != null) queryParams.Add("parameter", Configuration.ApiClient.ParameterToString(parameter)); // query parameter
            if (depth != null) queryParams.Add("depth", Configuration.ApiClient.ParameterToString(depth)); // query parameter



            if (cdrom.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(cdrom); // http body (model) parameter
            }
            else
            {
                postBody = cdrom; // byte array
            }

            // authentication (basicAuth) required

            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                headerParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }


            // make the HTTP request
            IRestResponse response = (IRestResponse)Configuration.ApiClient.CallApi(path_,
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
                throw new ApiException(statusCode, "Error calling Create: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException(statusCode, "Error calling Create: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<Image>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Image)Configuration.ApiClient.Deserialize(response, typeof(Image)));

        }
开发者ID:mechagrue,项目名称:profitbricks-sdk-net,代码行数:94,代码来源:AttachedCDROMsApi.cs

示例7: DrawImageUnscaled

 /// <summary>
 /// Implemented
 /// </summary>
 public void DrawImageUnscaled(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
 {
     if (image.GetType() != typeof(Bitmap))
         return;
     DrawBitmapData((Bitmap)image, x, y, width, height, false);
 }
开发者ID:djpnewton,项目名称:ddraw,代码行数:9,代码来源:SVGGraphics.cs

示例8: DrawImage

 /// <summary>
 /// Implemented
 /// </summary>
 public void DrawImage(Image image, Single x, Single y, Single width, Single height)
 {
     if (image.GetType() != typeof(Bitmap))
         return;
     DrawBitmapData((Bitmap)image, x, y, width, height, true);
 }
开发者ID:djpnewton,项目名称:ddraw,代码行数:9,代码来源:SVGGraphics.cs

示例9: Team_Tap

        private void Team_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Ellipse el = new Ellipse();
            string teamtype = "";
            Image i = new Image();

            if (sender.GetType() == el.GetType())
            {
                el = sender as Ellipse;
                teamtype = el.Name;
            }
            else if (sender.GetType() == i.GetType())
            {
                i = sender as Image;
                teamtype = i.Name;
            }

            NavigationService.Navigate(new Uri("/SelectTeam.xaml?action=" + teamtype + "&league=" + CurrentLeague, UriKind.Relative));
        }
开发者ID:jeffblankenburg,项目名称:FanaticApp,代码行数:19,代码来源:AddNewTicket.xaml.cs

示例10: FromImage

        public static Graphics FromImage(Image image)
        {
            if (image == null)
                throw new ArgumentNullException ("image");

            if ((image.PixelFormat & PixelFormat.Indexed) != 0)
                throw new Exception ("Cannot create Graphics from an indexed bitmap.");

            Bitmap b = image as Bitmap;
            if (b == null)
                throw new Exception ("Can not create Graphics contexts from " + image.GetType () + " Images, only Bitmaps are supported");
            var cgimage = b.NativeCGImage;

            if (b.bitmapBlock == IntPtr.Zero){
                throw new Exception ("Missing functionality: currently we can not create graphics contexts from bitmaps loaded from disk, need to do some extra work");
            }

            // Creates a context using the parameters that were used initially for the bitmap,
            // reusing the memory address space on it as well.
            var bitmapContext = new CGBitmapContext (b.bitmapBlock,
                                                     cgimage.Width,
                                                     cgimage.Height,
                                                     cgimage.BitsPerComponent,
                                                     cgimage.BytesPerRow,
                                                     cgimage.ColorSpace,
                                                     cgimage.AlphaInfo);

            return new Graphics (bitmapContext);
        }
开发者ID:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:29,代码来源:Graphics.cs

示例11: handlePlaylistPress

        private void handlePlaylistPress(Point target)
        {
            Image imageType = new Image();
            int emptySlot;
            IEnumerable<int> validSpaces;
            UIElement component = selectComponent(target);

            if (component != null)
            {
                if (component.GetType() == imageType.GetType())
                {
                    if (slots.Values.Contains((Image)component))
                    {

                        validSpaces =
                          from n in slots.Keys
                          where slots[n] == ((Image)component)
                          select n;
                        emptySlot = validSpaces.ElementAt(0);
                        slotFilled[emptySlot] = false;
                        slots[emptySlot].Source = null;

                        if (returnSlot.Keys.Contains(slots[emptySlot]))
                        {
                            returnSlot[slots[emptySlot]].Visibility = Visibility.Visible;
                            returnSlot.Remove((Image)(component));
                        }
                    }


                    else
                    {
                        emptySlot = firstEmpty();
                        if (emptySlot != -1)
                        {
                            slotFilled[emptySlot] = true;
                            noticeBox.Text = imageNames[slots[emptySlot]];
                            slots[emptySlot].Source = ((Image)component).Source;
                            playListPosition[(Image)component] = slots[emptySlot];
                            returnSlot.Add(slots[emptySlot], (Image)component);
                            component.Visibility = Visibility.Hidden;
                        }
                    }
                }
                else
                {
                  
                    for (int i = 0; i < 3; i++)
                    {
                        if (slots[i].Source != null)
                        {
                            playListVideos.Add(poseToVideo[slots[i].Source]);
                        }

                    }
                    positionInPlaylist = 0;
                    hideElements(currentCom);
                    focusedElementBorder.Visibility = Visibility.Hidden;
                    curPage = pageName.videoAndPractice;
                    currentCom = pageComponents[curPage];
                    unHideElements(currentCom);
                    moviePageLoaded(null);
 
                }
            }
            else noticeBox.Text = "No element in range";
        }
开发者ID:pajumed,项目名称:cs160-Pomegranit,代码行数:67,代码来源:MainWindow.xaml.cs


注:本文中的Image.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。