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


C# Image.Save方法代码示例

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


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

示例1: Execute

        public override bool Execute()
        {
            // Look for script-fu-selection-to-pattern as example. The basic idea
              // is to create a new image and save it as a .pat file

              var selection = ActiveImage.Selection;
              bool nonEmpty;
              var bounds = selection.Bounds(out nonEmpty);
              int width = bounds.Width;
              int height = bounds.Height;

              var image = new Image(width, height, ActiveImage.BaseType);
              var layer = new Layer(image, "test", width, height,
                ImageType.Rgb, 100,
                LayerModeEffects.Normal);
              image.InsertLayer(layer, 0);
              Console.WriteLine("{0} {1}", image.Width, image.Height);

              ActiveDrawable.EditCopy();
              layer.EditPaste(true);

              string filename = Gimp.Directory + System.IO.Path.DirectorySeparatorChar
            + "patterns" + System.IO.Path.DirectorySeparatorChar +
            _name + ".pat";

              image.Save(RunMode.Noninteractive, filename, filename);

              // Fix me: next lines should work so we can actually set the name
              // of the pattern!
              // Procedure procedure = new Procedure("file_pat_save");
              // procedure.Run(image, layer, filename, filename, _name);

              image.Delete();
              PatternList.Refresh();

              return false;
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:37,代码来源:MakePatternEvent.cs

示例2: Export


//.........这里部分代码省略.........
            Gl.glDisable(Gl.GL_CULL_FACE);
            Gl.glDisable(Gl.GL_LIGHTING);

            g.EnableBlendSrcAlpha();
            Gl.glDepthFunc( Gl.GL_LEQUAL );

            for (int chunkx = 0; chunkx < Math.Ceiling((double)picturewidth / windowwidth); chunkx++)
            {
                for (int chunky = 0; chunky < Math.Ceiling((double)pictureheight / windowheight); chunky++)
                {
                    Console.WriteLine("chunkx " + chunkx + " chunky " + chunky);

                    Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);		// Clear The Screen And Depth Buffer

                    foreach (RendererPass rendererpass in rendererpasses)
                    {
                        rendererpass.Apply();

                        Gl.glBegin(Gl.GL_QUADS);

                        double ul = (chunkx * windowwidth);
                        double ur = (chunkx * windowwidth + windowwidth);
                        double vt = (chunky * windowheight);
                        double vb = (chunky * windowheight + windowheight);
                        Gl.glTexCoord2d( ul,vt );
                        Gl.glMultiTexCoord2dARB(Gl.GL_TEXTURE1_ARB,ul, vt);
                        Gl.glVertex2i(0, 0);

                        Gl.glTexCoord2d( ul,vb );
                        Gl.glMultiTexCoord2dARB(Gl.GL_TEXTURE1_ARB,ul, vb);
                        Gl.glVertex2i(0, windowheight);

                        Gl.glTexCoord2d( ur,vb );
                        Gl.glMultiTexCoord2dARB(Gl.GL_TEXTURE1_ARB,ur, vb);
                        Gl.glVertex2i(windowwidth, windowheight);

                        Gl.glTexCoord2d( ur,vt );
                        Gl.glMultiTexCoord2dARB(Gl.GL_TEXTURE1_ARB,ur, vt);
                        Gl.glVertex2i(windowwidth, 0);

                        Gl.glEnd();
                    }

                    IntPtr ptr = Marshal.AllocHGlobal(windowwidth * windowheight * 4);
                    Gl.glReadPixels(0, 0, windowwidth, windowheight, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, ptr);
                    Marshal.Copy(ptr, buffer, 0, windowwidth * windowheight * 4);
                    Marshal.FreeHGlobal(ptr);

                    for (int x = 0; x < windowwidth; x++)
                    {
                        for (int y = 0; y < windowheight; y++)
                        {
                            if ((chunky * windowheight + y < pictureheight) &&
                                (chunkx * windowwidth + x < picturewidth))
                            {
                                int pixeloffset = (windowheight - y - 1) * windowwidth * 4 + x * 4;
                                //bitmap.SetPixel(x + chunkx * windowwidth, y + chunky * windowheight, System.Drawing.Color.FromArgb(buffer[pixeloffset + 0],
                                    //buffer[pixeloffset + 1], buffer[pixeloffset + 2]));
                                image.SetPixel(x + chunkx * windowwidth, y + chunky * windowheight,
                                    buffer[pixeloffset + 0],
                                    buffer[pixeloffset + 1],
                                    buffer[pixeloffset + 2],
                                    255
                                    );
                            }
                        }
                    }
                }
            }
            if (File.Exists(filepath))
            {
                File.Delete(filepath);
            }
            image.Save(filepath);
            //DevIL.DevIL.SaveBitmap( filepath, bitmap);

            Gl.glPopMatrix();
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glPopMatrix();
            Gl.glMatrixMode(Gl.GL_MODELVIEW);

            Gl.glEnable(Gl.GL_LIGHTING);

            g.ActiveTexture(1);
            g.DisableTexture2d();
            g.SetTextureScale(1);
            g.ActiveTexture(0);
            g.SetTextureScale(1);

            Gl.glEnable(Gl.GL_CULL_FACE);
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glDisable(Gl.GL_BLEND);

            g.EnableModulate();

            Gl.glViewport(0, 0, RendererSdl.GetInstance().OuterWindowWidth, RendererSdl.GetInstance().OuterWindowHeight);
            g.CheckError();

            MainUI.GetInstance().uiwindow.InfoMessage("Exported blended terrain texture to " + filepath);
        }
开发者ID:hughperkins,项目名称:SpringMapDesigner,代码行数:101,代码来源:ExportAsSingleTexture.cs

示例3: Insert

        public void Insert(int ProductId,string ImageFile,int SortOrder,string Caption,string CreatedBy,DateTime CreatedOn,string ModifiedBy,DateTime ModifiedOn)
        {
            Image item = new Image();

            item.ProductId = ProductId;

            item.ImageFile = ImageFile;

            item.SortOrder = SortOrder;

            item.Caption = Caption;

            item.CreatedBy = CreatedBy;

            item.CreatedOn = CreatedOn;

            item.ModifiedBy = ModifiedBy;

            item.ModifiedOn = ModifiedOn;

            item.Save(UserName);
        }
开发者ID:89sos98,项目名称:dashcommerce-3,代码行数:22,代码来源:ImageController.cs

示例4: Image_Save

        public void Image_Save()
        {
            Map m = new Map(10, 10);
            Image i1 = new Image(10, 10);
            m.Background = new Color("green");
            m.Render(i1);
            string filename = @".\data\tmp\" + Guid.NewGuid().ToString() + ".png";
            i1.Save(filename);

            MD5 md5 = MD5.Create();
            byte[] hash1 = md5.ComputeHash(File.ReadAllBytes(filename));
            byte[] hash2 = md5.ComputeHash(File.ReadAllBytes(@".\data\10x10green.png"));
            CollectionAssert.AreEqual(hash1, hash2);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:14,代码来源:ImageTests.cs

示例5: Save

        public void Save( string filename )
        {
            double[,] mesh = SlopeMap.GetInstance().GetSlopeMap();
            int width = mesh.GetUpperBound(0) + 1;
            int height = mesh.GetUpperBound(1) + 1;

            double maxslopetoexport = Config.GetInstance().SlopemapExportMaxSlope;

            Image image = new Image(width, height);
            //Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
            //Graphics g = Graphics.FromImage(bitmap);
            // cache pencolors;
            List<MovementAreaConfig> movementareas = Config.GetInstance().movementareas;
            SortedList<double, Color> sortedcolorbymaxslope = new SortedList<double, Color>();
            foreach (MovementAreaConfig movementarea in movementareas)
            {
                if (movementarea.MaxSlope >= 0)
                {
                    sortedcolorbymaxslope.Add(movementarea.MaxSlope, movementarea.color);
                }
                else
                {
                    sortedcolorbymaxslope.Add(double.PositiveInfinity, movementarea.color);
                }
            }
            for (int area = 0; area < sortedcolorbymaxslope.Count; area++)
            {
                LogFile.GetInstance().WriteLine(sortedcolorbymaxslope.Keys[area] + " " + sortedcolorbymaxslope.Values[area].ToString());
            }
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    Color colortouse = new Color(1, 1, 1);
                    for (int area = 0; area < sortedcolorbymaxslope.Count; area++)
                    {
                        if (mesh[i, j] < sortedcolorbymaxslope.Keys[area])
                        {
                            colortouse = sortedcolorbymaxslope.Values[area];
                            break;
                        }
                    }
                    int valuetowrite = (int)(mesh[i, j] * 255 / maxslopetoexport);
                    valuetowrite = Math.Max(0, valuetowrite);
                    valuetowrite = Math.Min(255, valuetowrite);
                    image.SetPixel(i, j, (byte)(colortouse.r * 255 * valuetowrite),
                        (byte)( colortouse.g * 255 * valuetowrite ),
                        (byte)( colortouse.b * 255 * valuetowrite ),
                        255
                    );
                }
            }
            image.Save(filename);
            exportheightmapfilename = filename;
            MainUI.GetInstance().uiwindow.InfoMessage("Slopemap exported");
        }
开发者ID:hughperkins,项目名称:SpringMapDesigner,代码行数:56,代码来源:SlopeMapPersistence.cs

示例6: Image_Save_NoExtension

 public void Image_Save_NoExtension()
 {
     Image im = new Image(256, 256);
     im.Save("foo");
 }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:5,代码来源:ImageTests.cs

示例7: Image_Save_InvalidFormat

 public void Image_Save_InvalidFormat()
 {
     Image im = new Image(256, 256);
     im.Save(@".\data\tmp\foo", "foo");
 }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:5,代码来源:ImageTests.cs

示例8: Save

 public void Save(string filename)
 {
     double[,] mesh = Terrain.GetInstance().Map;
     int width = mesh.GetUpperBound(0) + 1;
     int height = mesh.GetUpperBound(1) + 1;
     Image image = new Image(width, height);
     //Bitmap bitmap = new Bitmap( width, height, PixelFormat.Format24bppRgb );
     //Graphics g = Graphics.FromImage(bitmap);
     //Pen[] pens = new Pen[256];
     //for (int i = 0; i < 256; i++)
     //{
       //  pens[i] = new Pen(System.Drawing.Color.FromArgb(i, i, i));
     //}
     double minheight = Config.GetInstance().minheight;
     double maxheight = Config.GetInstance().maxheight;
     double heightmultiplier = 255 / (maxheight - minheight);
     for (int i = 0; i < width; i++)
     {
         for( int j = 0; j < height; j++ )
         {
             int normalizedmeshvalue = (int)( (mesh[i, j] - minheight) * heightmultiplier );
             normalizedmeshvalue = Math.Max( 0,normalizedmeshvalue );
             normalizedmeshvalue = Math.Min( 255,normalizedmeshvalue );
             byte normalizedmeshvaluebyte = (byte)normalizedmeshvalue;
             image.SetPixel(i, j, normalizedmeshvaluebyte, normalizedmeshvaluebyte, normalizedmeshvaluebyte, 255);
             //g.DrawRectangle(pens[ normalizedmeshvalue ], i, j, 1, 1);
         }
     }
     if (File.Exists(filename))
     {
         File.Delete(filename);
     }
     image.Save(filename);
     //DevIL.DevIL.SaveBitmap(filename, bitmap);
     //bitmap.Save(filename, ImageFormat.Bmp);
     Terrain.GetInstance().HeightmapFilename = filename;
     Terrain.GetInstance().OnTerrainModified();
     MainUI.GetInstance().uiwindow.InfoMessage("Heightmap saved");
 }
开发者ID:hughperkins,项目名称:SpringMapDesigner,代码行数:39,代码来源:HeightMapPersistence.cs

示例9: SaveTerrain

        public void SaveTerrain(bool fastSave)
        {
            int textureCount = 6;
            Image[] textures = new Image[textureCount];
            for (int i = 0; i < textureCount; i++)
            {
                textures[i] = new Image();
                textures[i].Load("splatting" + i + ".png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            }

            if (!fastSave)
            {
                Image baseTexture = new Image();
                Map.mSMgr.CreateBaseTexture(baseTexture, Constants.Land.SimplemapSize, Constants.Land.SimplemapSize, textures, 40, 40);
                baseTexture.Save(MapFolder + "baseTexture.jpg");
            }

            Image splatting = new Image();
            Map.mSMgr.SaveMapToImage(0, splatting);
            splatting.Save(MapFolder + "textureMap0.png");
            splatting = new Image();
            Map.mSMgr.SaveMapToImage(1, splatting);
            splatting.Save(MapFolder + "textureMap1.png");

            Image heightMap = new Image();
            MET.TerrainInfo.SaveHeightmapToImage(Map.mTInfo, heightMap);
            heightMap.Save(MapFolder + "heightMap.png");

            if (!fastSave)
            {
                uint bigsize = Constants.Land.SimplemapSize;
                Image lmImage = new Image();
                MET.TerrainInfo.CreateTerraingLightmap(Map.mTInfo, lmImage, bigsize, bigsize, new Vector3(1, -1.5f, 1), new ColourValue(1, 1, 1), new ColourValue(0.6f, 0.6f, 0.6f), true);
                Image cmImage = new Image();
                Map.mSMgr.CreateBaseTexture(cmImage, bigsize, bigsize, textures, 20, 20);

                System.Drawing.Bitmap mmImage = new System.Drawing.Bitmap((int)bigsize, (int)bigsize);

                for (int y = 0; y < cmImage.Width; ++y)
                {
                    for (int x = 0; x < cmImage.Height; ++x)
                    {
                        float r = cmImage.GetColourAt(x, y, 0).r * lmImage.GetColourAt(x, y, 0).r;
                        float g = cmImage.GetColourAt(x, y, 0).g * lmImage.GetColourAt(x, y, 0).g;
                        float b = cmImage.GetColourAt(x, y, 0).b * lmImage.GetColourAt(x, y, 0).b;
                        mmImage.SetPixel(x, y, System.Drawing.Color.FromArgb((byte)(255 * r), (byte)(255 * g), (byte)(255 * b)));
                    }
                }

                mmImage.Save(MapFolder + "miniMap.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }
开发者ID:Serebriakov,项目名称:rybrcoul-games,代码行数:52,代码来源:MapEditor.cs

示例10: _camera_PreviewFrameAvailable

        private async void _camera_PreviewFrameAvailable(object sender, PreviewArrivedEventArgs e)
        {
            try
            {
                _stream = new MemoryStream(e.Frame.ImageStream);

                if (null == _stream)

                    return;

                await Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() =>
                    {
                        try
                        {

                            _bitmapImage = new BitmapImage();
                            _bitmapImage.BeginInit();
                            _bitmapImage.StreamSource = _stream; // Copy stream to local
                            _bitmapImage.EndInit();
                            cam.Source = _bitmapImage;
                            if (isRecording)
                            {
                                using (Image<Bgr, byte> rec_frame = new Image<Bgr, byte>(UiHandler.Bmimg2Bitmap(_bitmapImage)))
                                {
                                    rec_frame.Save(AppDomain.CurrentDomain.BaseDirectory + "img\\" + (++index) + ".jpg");
                                }
                            }
                        }

                        catch (Exception ex)
                        {
                            // ignored
                        }
                    }));
            }
            catch (Exception)
            {
                // ignored
            }
        }
开发者ID:kylezhaoxc,项目名称:Kyle_Emgu,代码行数:42,代码来源:MainWindow.xaml.cs

示例11: WriteSlice

 public void WriteSlice(Image image, string path, string name, 
     bool useGlobalExtension)
 {
     var clone = new Image(image);
       clone.Crop(Width, Height, X1, Y1);
       string filename = path + System.IO.Path.DirectorySeparatorChar +
     GetFilename(name, useGlobalExtension);
       clone.Save(RunMode.Noninteractive, filename, filename);
       clone.Delete();
 }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:10,代码来源:Rectangle.cs

示例12: saveImage

 /// <summary>
 /// Save image on Desktop
 /// </summary>
 /// <param name="image">image data as Image Gray,float </param>
 /// <param name="filename">your file name with ext like jpg</param>
 public static void saveImage(Image<Gray,float> image,String filename)
 {
     String dir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
     String path = dir + "\\" + filename;
     image.Save(path);
 }
开发者ID:sroske,项目名称:i-recognize-you,代码行数:11,代码来源:Tools.cs


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