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


C# FIBITMAP类代码示例

本文整理汇总了C#中FIBITMAP的典型用法代码示例。如果您正苦于以下问题:C# FIBITMAP类的具体用法?C# FIBITMAP怎么用?C# FIBITMAP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Decode

        public byte[] Decode(PdfObject decodedObject, byte[] inputData, DecodeParameters decodeParameters)
        {
            FIBITMAP myImage = new FIBITMAP();
            using (MemoryStream stream = new MemoryStream(inputData))
            {
                myImage = FreeImage.LoadFromStream(stream);
            }

            Bitmap bitmap = FreeImage.GetBitmap(myImage);

            decodedObject.ColorSpace = ColorSpace.RGB;

            byte[] result = new byte[decodedObject.Width * decodedObject.Height * 3];

            for (int i = 0; i < decodedObject.Width; i++)
            {
                for (int j = 0; j < decodedObject.Height; j++)
                {
                    Color pixel = bitmap.GetPixel(i, j);

                    int index = j * decodedObject.Width + i;
                    result[index * 3] = pixel.R;
                    result[index * 3 + 1] = pixel.G;
                    result[index * 3 + 2] = pixel.B;
                }
            }

            return result;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:29,代码来源:JpxDecoder.cs

示例2: fiGetMetaData

        public List<MetaSimple> fiGetMetaData(FIBITMAP bm)
        {
            List<MetaSimple> results = new List<MetaSimple>();

            // Create a wrapper for all metadata the image contains
            ImageMetadata iMetadata = new ImageMetadata(bm);

            // Get each metadata model
            foreach (MetadataModel metadataModel in iMetadata)
            {
                // Get each metadata tag and create a subnode for it
                foreach (MetadataTag metadataTag in metadataModel)
                {
                    MetaSimple tagValue = new MetaSimple();

                    tagValue.ModelName = metadataModel.ToString();
                    tagValue.ModelTag = metadataTag.Key;
                    tagValue.TagValue = metadataTag;

                    results.Add(tagValue);
                }

            }

            return results;
        }
开发者ID:Eggy1968,项目名称:FNM,代码行数:26,代码来源:FreeImageMethods.cs

示例3: MetadataModel

 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="dib"/> is null.</exception>
 protected MetadataModel(FIBITMAP dib)
 {
     if (dib.IsNull)
     {
         throw new ArgumentNullException("dib");
     }
     this.dib = dib;
 }
开发者ID:barsnadcat,项目名称:steelandconcrete,代码行数:14,代码来源:MetadataModel.cs

示例4: bLoad_Click

        private void bLoad_Click(object sender, EventArgs e)
        {
            // Create variables
            OpenFileDialog ofd = new OpenFileDialog();
            FIBITMAP dib = new FIBITMAP();
            try
            {
                // Apply settings
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                ofd.FileName = "";
                ofd.Filter = "All files (*.*)|*.*";
                ofd.Multiselect = false;
                ofd.RestoreDirectory = true;
                // Get image filename
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    // Load the image
                    dib = FreeImage.LoadEx(ofd.FileName);
                    // Check if image was loaded successfully
                    if (dib.IsNull) throw new Exception("Failed to load image.");
                    // Clear the treeview
                    tvMetadata.Nodes.Clear();
                    // Create a wrapper for all metadata the image contains
                    ImageMetadata iMetadata = new ImageMetadata(dib);
                    // Get each metadata model
                    foreach (MetadataModel metadataModel in iMetadata)
                    {
                        // Create a new node for each model
                        TreeNode modelNode = tvMetadata.Nodes.Add(metadataModel.ToString());

                        // Get each metadata tag and create a subnode for it
                        foreach (MetadataTag metadataTag in metadataModel)
                        {
                            modelNode.Nodes.Add(metadataTag.Key + ": " + metadataTag.ToString());
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Operation aborted.", "Aborted");
                }
            }
            // Display error message
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                    ex = ex.InnerException;
                MessageBox.Show(ex.ToString(), "Exception caught");
            }
            // Clean up
            finally
            {
                ofd.Dispose();
                FreeImage.UnloadEx(ref dib);
            }
        }
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:57,代码来源:MainForm.cs

示例5: CleanUpResources

 public static void CleanUpResources(FIBITMAP dib)
 {
     // The bitmap was saved to disk but is still allocated in memory, so the handle has to be freed.
       if (!dib.IsNull) {
     FreeImage.Unload(dib);
       }
       // Make sure to set the handle to null so that it is clear that the handle is not pointing to a bitmap.
       dib = FIBITMAP.Zero;
 }
开发者ID:dotob,项目名称:wop,代码行数:9,代码来源:ImageWorker.cs

示例6: buildFiBitmap

        /// <summary>
        /// Builds an FIBitmap from the stream and job.Settings 
        /// </summary>
        /// <param name="s"></param>
        /// <param name="job"></param>
        /// <returns></returns>
        protected FIBITMAP buildFiBitmap(ref FIBITMAP original, ImageJob job, bool supportsTransparency, bool mayUnloadOriginal)
        {
            ResizeSettings settings = job.Settings;
            if (original.IsNull) return FIBITMAP.Zero;
            FIBITMAP final = FIBITMAP.Zero;

            //Find the image size
            Size orig = new Size((int)FreeImage.GetWidth(original), (int)FreeImage.GetHeight(original));

            //Calculate the new size of the image and the canvas.
            ImageState state = new ImageState(settings, orig, true);
            c.CurrentImageBuilder.Process(state);
            RectangleF imageDest = PolygonMath.GetBoundingBox(state.layout["image"]);

            if (imageDest.Width != orig.Width || imageDest.Height != orig.Height) {
                //Rescale
                bool temp;
                final = FreeImage.Rescale(original, (int)imageDest.Width, (int)imageDest.Height, FreeImageScalingPlugin.ParseResizeAlgorithm(settings["fi.scale"], FREE_IMAGE_FILTER.FILTER_BOX, out temp));
                if (mayUnloadOriginal) FreeImage.UnloadEx(ref original);
                if (final.IsNull) return FIBITMAP.Zero;
            } else {
                final = original;
            }

            RGBQUAD bgcolor = default(RGBQUAD);
            bgcolor.Color = settings.BackgroundColor;
            if (settings.BackgroundColor == Color.Transparent && !supportsTransparency)
                bgcolor.Color = Color.White;

            //If we need to leave padding, do so.
            BoxPadding outsideImage = new BoxPadding(imageDest.Left, imageDest.Top, state.destSize.Width - imageDest.Right, state.destSize.Height - imageDest.Bottom);

            if (outsideImage.All != 0) {
                var old = final;
                //Extend canvas
                final = FreeImage.EnlargeCanvas<RGBQUAD>(old,
                            (int)outsideImage.Left, (int)outsideImage.Top, (int)outsideImage.Right, (int)outsideImage.Bottom,
                            bgcolor.Color != Color.Transparent ? new Nullable<RGBQUAD>(bgcolor) : null,
                            FREE_IMAGE_COLOR_OPTIONS.FICO_RGBA);
                if (old == original) {
                    if (mayUnloadOriginal) {
                        FreeImage.UnloadEx(ref original);
                        old = original;
                    }
                } else {
                    FreeImage.UnloadEx(ref old); //'old' has the original value of 'final', which we allocated.
                }
                if (final.IsNull) return FIBITMAP.Zero;
            }

            return final;
        }
开发者ID:stukalin,项目名称:ImageResizer,代码行数:58,代码来源:FreeImageBuilder.cs

示例7: bLoadUrl_Click

 private void bLoadUrl_Click(object sender, EventArgs e)
 {
     // Verify url
     if (String.IsNullOrEmpty(tbURL.Text))
     {
         MessageBox.Show("Please enter a valid URL.", "Error");
         return;
     }
     FIBITMAP dib = new FIBITMAP();
     Stream sourceStream = null;
     try
     {
         // Build a stream to read from
         WebRequest request = (WebRequest)HttpWebRequest.Create(tbURL.Text);
         WebResponse response = request.GetResponse();
         sourceStream = response.GetResponseStream();
         if (sourceStream == null)
         {
             throw new Exception();
         }
         // Load the image from stream
         dib = FreeImage.LoadFromStream(sourceStream);
         // Check success
         if (dib.IsNull)
         {
             throw new Exception();
         }
         // Convert the bitmap into a .NET bitmap
         Bitmap bitmap = FreeImage.GetBitmap(dib);
         if (bitmap == null)
         {
             throw new Exception();
         }
         // Show the bitmap
         if (picBox.Image != null)
         {
             picBox.Image.Dispose();
         }
         picBox.Image = bitmap;
     }
     catch
     {
         // Error handling
         MessageBox.Show("Error loading URL.", "Error");
     }
     finally
     {
         // Clean up memory
         FreeImage.UnloadEx(ref dib);
         if (sourceStream != null) sourceStream.Dispose();
     }
 }
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:52,代码来源:SampleForm.cs

示例8: FIICCPROFILE

 /// <summary>
 /// Creates a new ICC-Profile for <paramref name="dib"/>.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 /// <param name="data">The ICC-Profile data.</param>
 /// <param name="size">Number of bytes to use from data.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="dib"/> is null.</exception>
 public unsafe FIICCPROFILE(FIBITMAP dib, byte[] data, int size)
 {
     if (dib.IsNull)
     {
         throw new ArgumentNullException("dib");
     }
     FIICCPROFILE prof;
     size = Math.Min(size, (int)data.Length);
     prof = *(FIICCPROFILE*)FreeImage.CreateICCProfile(dib, data, size);
     this.flags = prof.flags;
     this.size = prof.size;
     this.data = prof.data;
 }
开发者ID:barsnadcat,项目名称:steelandconcrete,代码行数:21,代码来源:FIICCPROFILE.cs

示例9: fiLoadImage

        public FIBITMAP fiLoadImage(string fileName)
        {
            FIBITMAP bm = new FIBITMAP();

            try
            {
                // Load the image
                bm = FreeImage.LoadEx(fileName);
            }
            catch (Exception)
            {
                throw new Exception("Failed to load image.");
            }

            return bm;
        }
开发者ID:Eggy1968,项目名称:FNM,代码行数:16,代码来源:FreeImageMethods.cs

示例10: MDM_EXIF_EXIF

 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 public MDM_EXIF_EXIF(FIBITMAP dib)
     : base(dib)
 {
 }
开发者ID:abhishekbhalani,项目名称:freeimage,代码行数:8,代码来源:MetadataModels.cs

示例11: FreeImageAlgorithmsBitmap

 public FreeImageAlgorithmsBitmap(FIBITMAP dib)
     : base(dib)
 {
 }
开发者ID:glennpierce,项目名称:Fia,代码行数:4,代码来源:FreeImageAlgorithms.cs

示例12: MDM_NODATA

 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 public MDM_NODATA(FIBITMAP dib)
     : base(dib)
 {
 }
开发者ID:abhishekbhalani,项目名称:freeimage,代码行数:8,代码来源:MetadataModels.cs

示例13: MDM_XMP

 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 public MDM_XMP(FIBITMAP dib)
     : base(dib)
 {
 }
开发者ID:abhishekbhalani,项目名称:freeimage,代码行数:8,代码来源:MetadataModels.cs

示例14: MDM_MAKERNOTE

 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 public MDM_MAKERNOTE(FIBITMAP dib)
     : base(dib)
 {
 }
开发者ID:abhishekbhalani,项目名称:freeimage,代码行数:8,代码来源:MetadataModels.cs

示例15: MDM_MAIN

 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="dib">Handle to a FreeImage bitmap.</param>
 public MDM_MAIN(FIBITMAP dib)
     : base(dib)
 {
 }
开发者ID:abhishekbhalani,项目名称:freeimage,代码行数:8,代码来源:MetadataModels.cs


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