예제 #1
0
        /// <summary>
        /// 裁剪一张图片,按照指定的宽高
        /// </summary>
        /// <param name="path">图片路径</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <param name="savePath">保存的路径</param>
        /// <returns>是否裁剪成功</returns>
        public static bool CutImg(string path, int width, int height, string savePath)
        {
            if (FileCommon.Exists(path))
            {
                try
                {
                    Bitmap bitmap = new Bitmap(path);
                    using (Bitmap image = ImageClass.MakeThumbnail(bitmap, width, height))
                    {
                        //释放原图片线程,因为有可能要覆盖原文件
                        bitmap.Dispose();

                        /*
                         *  默认是按照System.Drawing.Imaging.ImageFormat.Bmp保存
                         *  指定图片存储存储格式,默认是bmp(所以会把一张1mb的图片生成出8mb)
                         */
                        image.Save(savePath, GetImageFormat(Path.GetExtension(path)));
                        return(true);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(false);
        }
예제 #2
0
		public void WriteReadImage()
		{
			
			ImageClass ima = new ImageClass();
			Bitmap bmp  = new Bitmap(20, 10);
			bmp.SetPixel(10, 5, Color.Gainsboro);
			bmp.SetPixel(10, 7, Color.Navy);
			ima.MyImage = bmp;

			FileHelperEngine engine = new FileHelperEngine(typeof(ImageClass));
			string data = engine.WriteString((IList) new object[] {ima});
			
			ImageClass[] res = (ImageClass[]) engine.ReadString(data);
			
			Assert.AreEqual(1, res.Length);
			Assert.IsNotNull(res[0].MyImage);
			Assert.AreEqual(typeof(Bitmap), res[0].MyImage.GetType());
			Assert.AreEqual(Color.Gainsboro.R, ((Bitmap)res[0].MyImage).GetPixel(10, 5).R);
			Assert.AreEqual(Color.Gainsboro.G, ((Bitmap)res[0].MyImage).GetPixel(10, 5).G);
			Assert.AreEqual(Color.Gainsboro.B, ((Bitmap)res[0].MyImage).GetPixel(10, 5).B);
			Assert.AreEqual(Color.Navy.R, ((Bitmap)res[0].MyImage).GetPixel(10, 7).R);
			Assert.AreEqual(Color.Navy.G, ((Bitmap)res[0].MyImage).GetPixel(10, 7).G);
			Assert.AreEqual(Color.Navy.B, ((Bitmap)res[0].MyImage).GetPixel(10, 7).B);

		}
예제 #3
0
        public override void ViewWillAppear(bool animated)
        {
            InvokeOnMainThread(() =>
            {
                base.ViewWillAppear(animated);
                BTProgressHUD.Show("Loading Image", maskType: ProgressHUD.MaskType.Black);
                scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
                View.AddSubview(scrollView);
                image     = ImageClass.FromUrl(filepath);
                imageView = new UIImageView(image);
                scrollView.ContentSize = imageView.Image.Size;
                scrollView.AddSubview(imageView);

                scrollView.MaximumZoomScale            = 3f;
                scrollView.MinimumZoomScale            = .1f;
                scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(imageView); };

                UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap)
                {
                    NumberOfTapsRequired = 2 // double tap
                };

                scrollView.AddGestureRecognizer(doubletap); // detect when the scrollView is double-tapped
                scrollView.SetZoomScale(0.25f, true);

                BTProgressHUD.Dismiss();
            });
        }
예제 #4
0
        private void udmKeyPress()
        {
            // Getting Index of Current Row
            int index = gridViewProduct.CurrentRow.Index;

            DataGridViewRow Row = this.gridViewProduct.Rows[index];

            labelProductID.Text     = Row.Cells["ProductID"].Value.ToString();
            comboBocCategory.Text   = Row.Cells["CategoryName"].Value.ToString();
            textBoxProductType.Text = Row.Cells["ProductType"].Value.ToString();
            textBoxBrand.Text       = Row.Cells["ProductBrand"].Value.ToString();
            textBoxSize.Text        = Row.Cells["ProductSize"].Value.ToString();
            textBoxColour.Text      = Row.Cells["ProductColor"].Value.ToString();
            textBoxBarcode.Text     = Row.Cells["Barcode"].Value.ToString();
            string pImage = Row.Cells["ProductImage"].Value.ToString();

            if (pImage == "ImageClass.GetImageFromBase64(Row.Cells[ProductImage].Value.ToString())' threw an exception of type 'System.FormatException" || pImage == "" || pImage == "NoImage")
            {
                pictureBoxProduct.Visible     = false;
                labelAfterHiddenImage.Visible = true;
                labelAfterHiddenImage.Text    = "NoImage";
            }
            else
            {
                pictureBoxProduct.Visible     = true;
                labelAfterHiddenImage.Visible = false;
                pictureBoxProduct.Image       = ImageClass.GetImageFromBase64(Row.Cells["ProductImage"].Value.ToString());
            }
        }
예제 #5
0
        private void editItemButton_Click(object sender, EventArgs e)
        {
            string convertedImage = ImageClass.prepareImageToString(imgLocation);

            if (ValidateForm().Keys.First())
            {
                ItemModel model = new ItemModel(
                    editItemItemText.Text,
                    editItemAssetText.Text,
                    editItemArrivedText.Text,
                    editItemInvoiceText.Text,
                    editItemCcdText.Text,
                    editItemNameRusText.Text,
                    editItemPositionCcdText.Text,
                    editItemStatusText.Text,
                    editItemBoxText.Text,
                    editItemContainerText.Text,
                    editItemCommentText.Text,
                    convertedImage
                    );

                ApiHelpers.ApiConnectorHelper.EditData <ItemModel>(item_id.ToString(), model, pathItemsEdit);
            }
            else
            {
                ErrorForm errorForm = new ErrorForm(ValidateForm().Values.First());
                errorForm.Show();
            }
        }
예제 #6
0
        private void buttonUpdateProduct_Click(object sender, EventArgs e)
        {
            bool   Status        = false;
            string StatusDetails = null;

            try
            {
                if (comboBocCategory.Text == "" || textBoxProductType.Text == "" || textBoxBrand.Text == "" ||
                    textBoxSize.Text == "" || textBoxColour.Text == "" || textBoxBarcode.Text == "")
                {
                    JIMessageBox.ExclamationMessage("Fill All Fields !"); return;
                }
                string Photo = ImageClass.GetBase64StringFromImage(Imager.Resize(pictureBoxProduct.Image, 200, 200, true)); //Resize & Convert to String

                MainClass.POS.usp_UpdateProduct(Convert.ToInt32(labelProductID.Text),
                                                Convert.ToInt32(comboBocCategory.SelectedValue), textBoxProductType.Text,
                                                textBoxBrand.Text, textBoxSize.Text, textBoxColour.Text, Photo, textBoxBarcode.Text,
                                                out Status, out StatusDetails);
                if (Status)
                {
                    JIMessageBox.InformationMessage("Record Updated Succesfully !");
                    displayProduct();
                    //  clearTextBox();
                }
                else
                {
                    MessageBox.Show(StatusDetails, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #7
0
        /// <summary>
        /// 调整锐度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void trackBar3_ValueChanged(object sender, EventArgs e)
        {
            if (bmOk != null)
            {
                try
                {
                    int      val = trackBar3.Value;
                    Bitmap   bm  = new Bitmap(800, 800);
                    Graphics g   = Graphics.FromImage(bm);
                    g.DrawImage(pictureBox1.Image, 0, 0);
                    g.Dispose();

                    Bitmap bms = ImageClass.Sharpen(bm, val);
                    //bm.Dispose();
                    if (bms != null)
                    {
                        pictureBox1.Image = bms;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("调整亮度出错:" + ex);
                }
            }
        }
예제 #8
0
        private void BtnMeteo_Click(object sender, RoutedEventArgs e)
        {
            Util.StopTask();

            Task.Run(() =>
            {
                DateTime update = DateTime.Now.AddMinutes(-10);
                int task        = Util.StartTask();

                while (Util.TaskWork(task))
                {
                    if (Util.Context.Meteo != null)
                    {
                        ImageClass imageClass = new ImageClass(MeteoImgs.GetName(Util.Context.Meteo.weather.icon).FileName);
                        imageClass.SetÞixelFrame(0, Util.Context.Pixels, 0, false);
                    }

                    Util.Context.Pixels.SetMeteo(Util.Context.Meteo);
                    Util.SetLeds();
                    Util.Context.Pixels.Reset();

                    if (update.AddMinutes(5) < DateTime.Now)
                    {
                        update = DateTime.Now;
                        Util.UpdateMeteo();
                    }
                }
            });
        }
예제 #9
0
        private void gridViewProduct_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    DataGridViewRow Row = this.gridViewProduct.Rows[e.RowIndex];

                    labelProductID.Text     = Row.Cells["ProductID"].Value.ToString();
                    comboBocCategory.Text   = Row.Cells["CategoryName"].Value.ToString();
                    textBoxProductType.Text = Row.Cells["ProductType"].Value.ToString();
                    textBoxBrand.Text       = Row.Cells["ProductBrand"].Value.ToString();
                    textBoxSize.Text        = Row.Cells["ProductSize"].Value.ToString();
                    textBoxColour.Text      = Row.Cells["ProductColor"].Value.ToString();
                    textBoxBarcode.Text     = Row.Cells["Barcode"].Value.ToString();
                    string pImage = Row.Cells["ProductImage"].Value.ToString();
                    if (pImage == "ImageClass.GetImageFromBase64(Row.Cells[ProductImage].Value.ToString())' threw an exception of type 'System.FormatException" || pImage == "" || pImage == "NoImage")
                    {
                        pictureBoxProduct.Visible     = false;
                        labelAfterHiddenImage.Visible = true;
                        labelAfterHiddenImage.Text    = "NoImage";
                    }
                    else
                    {
                        pictureBoxProduct.Visible     = true;
                        labelAfterHiddenImage.Visible = false;
                        pictureBoxProduct.Image       = ImageClass.GetImageFromBase64(Row.Cells["ProductImage"].Value.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                JIMessageBox.ErrorMessage(ex.Message);
            }
        }
예제 #10
0
        public void   ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";


            //获取图片的缩略图——定义一个较小的画布,在画布上重画该张图片
            string filePath = context.Request.MapPath("/ImageUpLoad/1.jpg");

            //创建一个图片
            using (Image img = Image.FromFile(filePath))
            {
                //设置画布大写,以图片为背景
                //我们不绘制其他的图案,直接把缩小的背景保存为图片,这就是原来图片的缩略图
                using (Bitmap map = new Bitmap(img, img.Width / 3, img.Height / 3))
                {
                    //定义图片的名称
                    string fileName = Guid.NewGuid().ToString();
                    //保存缩小的图片
                    map.Save(context.Request.MapPath("/ImageUpLoad/" + fileName + "_缩略图" + ".png"), System.Drawing.Imaging.ImageFormat.Jpeg);

                    context.Response.Write("<html><body><img src='" + "/ImageUpLoad/" + fileName + "_缩略图" + ".png '>" + "</body></html>");
                }
            }


            //调用ImageClass类中对图像处理的方法,给图片加水印
            //注意LetterWatermark返回的是图片加水印的新的图片的绝对路径,这个绝对路径在下面的src中,使用出错,尽量还是使用相对路径吧
            string Path = ImageClass.LetterWatermark(filePath, 50, "--test--", Color.Blue, "B");

            context.Response.Write("<html><body><img src='" + "/ImageUpLoad/1.jpg" + "'></body></html>");
        }
예제 #11
0
 private void GameArsenalForms_Load(object sender, EventArgs e)
 {
     ImageClass = new ImageClass();
     ColumnsDatagrid();
     ModeVisible(this.startBattle);
     CarryWarArsenal();
 }
예제 #12
0
        public IActionResult UploadImg(IFormFile imgfile)
        {
            ImageClass ic       = new ImageClass();
            var        fileInfo = AccessWWWRoot();

            ic.FileImages = fileInfo;

            if (imgfile == null)
            {
                ic.Message = "Please select a valid Image.";
                return(View(ic));
            }

            var saveimg = Path.Combine(_webhost.WebRootPath, "img/pizza", imgfile.FileName);

            var imgtext = Path.GetExtension(imgfile.FileName);

            if (imgtext == ".jpg" || imgtext == ".png")
            {
                using (var uploadimg = new FileStream(saveimg, FileMode.Create))
                {
                    imgfile.CopyTo(uploadimg);
                    ic.Message = $"The selected file {imgfile.FileName} is saved successfully.";
                }
            }
            else
            {
                ic.Message = $"Only the img file types .jpg or .png can be uploaded!";
            }

            fileInfo      = AccessWWWRoot();
            ic.FileImages = fileInfo;

            return(View(ic));
        }
예제 #13
0
        public void WriteReadImage()
        {
            var ima = new ImageClass();
            var bmp = new Bitmap(20, 10);

            bmp.SetPixel(10, 5, Color.Gainsboro);
            bmp.SetPixel(10, 7, Color.Navy);
            ima.MyImage = bmp;

            var engine = new FileHelperEngine <ImageClass>();

            string data = engine.WriteString(new ImageClass[] { ima });

            ImageClass[] res = engine.ReadString(data);

            Assert.AreEqual(1, res.Length);
            Assert.IsNotNull(res[0].MyImage);
            Assert.AreEqual(typeof(Bitmap), res[0].MyImage.GetType());
            Assert.AreEqual(Color.Gainsboro.R, ((Bitmap)res[0].MyImage).GetPixel(10, 5).R);
            Assert.AreEqual(Color.Gainsboro.G, ((Bitmap)res[0].MyImage).GetPixel(10, 5).G);
            Assert.AreEqual(Color.Gainsboro.B, ((Bitmap)res[0].MyImage).GetPixel(10, 5).B);
            Assert.AreEqual(Color.Navy.R, ((Bitmap)res[0].MyImage).GetPixel(10, 7).R);
            Assert.AreEqual(Color.Navy.G, ((Bitmap)res[0].MyImage).GetPixel(10, 7).G);
            Assert.AreEqual(Color.Navy.B, ((Bitmap)res[0].MyImage).GetPixel(10, 7).B);
        }
예제 #14
0
 private void empoyeeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     if (CheckEmptyTextBoxes())
     {
         if (empoyeeBindingSource == null)
         {
             return;
         }
         Validate();
         if (employeePhotoPictureBox.Image != null)
         {
             ((Empoyee)empoyeeBindingSource.Current).EmployeePhoto =
                 ImageClass.ImageToByte(employeePhotoPictureBox.Image);
         }
         empoyeeBindingSource.EndEdit();
         var iResult = EmployeeManager.Save((Empoyee)empoyeeBindingSource.Current);
         if (iResult > 0)
         {
             MessageBox.Show(@"Record successfully saved.", @"Save", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(@"Error in saving.", @"Save", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show(@"Please fill-out required field.", @"Required", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
예제 #15
0
        private void createUser()
        {
            bool   Status        = false;
            string StatusDetails = null;

            try
            {
                ModelClass.ModelPOS.ModelUser md = new ModelClass.ModelPOS.ModelUser();
                md.Role_ID          = int.Parse(cbRoles.SelectedValue.ToString());
                md.UserName         = tbName.Text.ToString();
                md.UserPassword     = tbPassword.Text.ToString();
                md.ContactNo        = tbphone.Text.ToString();
                md.UserDesignation  = tbDesignation.Text.ToString();
                md.CreatedByUser_ID = ModelClass._UserID;                //UserID_Static
                Bitmap img   = ImageClass.Resize((Bitmap)pictureBoxUser.Image, new Size(200, 200), System.Drawing.Imaging.ImageFormat.Jpeg);
                string Photo = ImageClass.GetBase64StringFromImage(img); //Resize & Convert to String
                md.UserPicture = Photo;
                MainClass.POS.CRUDUserCreate(md, out Status, out StatusDetails);
                if (Status)
                {
                    JIMessageBox.InformationMessage(StatusDetails);
                    Clear();
                }
                else
                {
                    MessageBox.Show(StatusDetails, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                gridViewUser.Rows.Clear();
                displayUser();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #16
0
        /// <summary>
        /// This is specificed Command
        /// </summary>
        private void OpenImage()
        {
            Console.WriteLine("Executing OpenImage");

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title  = "Select a image for OCR";
            openFileDialog.Filter = "All supported graphics |*.jpg; *.jpeg;*.png|" +
                                    "JPEG(*.jpg;*.jpeg)|*.jpg; *.jpeg|" +
                                    "Portable Network Graphic (*.png)|*.png";
            if (openFileDialog.ShowDialog() == true)
            {
                //inputImage.Source = new BitmapImage(new Uri(openFileDialog.FileName));
                ////textEditor.Text = openFileDialog.FileName;
                //textEditor.Text = "Click Run button to see the results";
                //img_Src = openFileDialog.FileName;
                //ocr = new TesseractEngine("./tessdata", "eng", EngineMode.TesseractAndCube);
                //btnRun.IsEnabled = true;
                //toolRun.IsEnabled = true;
                var filename = openFileDialog.FileName;
                var bitmap   = new BitmapImage(new Uri(filename));

                ImageOne = new ImageClass
                {
                    FilePath = filename,
                    Image    = bitmap
                };

                OutPutText = "Click RUN button to start OCR demo";
            }
        }
예제 #17
0
        /// <summary>
        /// ShowAnimation
        /// </summary>
        /// <param name="file"></param>
        private void ShowAnimation(string file)
        {
            Task.Run(() =>
            {
                int task  = Util.StartTask();
                int frame = 0;

                //Fade Out
                if (!string.IsNullOrWhiteSpace(LastAutorun))
                {
                    ImageClass imageClassLastAutorun = new ImageClass(LastAutorun);

                    for (int slide = 0; slide < imageClassLastAutorun.Width; slide++)
                    {
                        SetAnimation(imageClassLastAutorun, frame++, slide, true);
                    }
                }

                ImageClass imageClass = new ImageClass(file);

                //Fade In
                for (int slide = imageClass.Width; slide >= 0; slide--)
                {
                    SetAnimation(imageClass, frame++, slide);
                }

                LastAutorun = file;

                //Animation
                while (imageClass.Animation && Util.TaskWork(task))
                {
                    SetAnimation(imageClass, frame++, 0);
                }
            });
        }
예제 #18
0
        public ImageInfoClass LoadInfo(ImageClass imgHandler)
        {
            ImageInfoClass info     = new ImageInfoClass();
            FileInfo       fileInfo = new FileInfo(imgHandler.FilePath);

            info.Name      = fileInfo.Name.Replace(fileInfo.Extension, "");
            info.Extension = fileInfo.Extension;
            string _label13_ori = fileInfo.DirectoryName;

            if (_label13_ori.Length > 50)
            {
                _label13_ori = _label13_ori.Substring(0, 10) + "..." +
                               _label13_ori.Substring(_label13_ori.LastIndexOf("\\"));
            }
            info.Directory = _label13_ori;

            info.Dimension = (int)imgHandler.Image.Width + "x" + (int)imgHandler.Image.Height;
            info.Size      = (fileInfo.Length / 1024.0).ToString("0.0") + "KB";
            info.CreateOn  = fileInfo.CreationTime.ToString("dddd MMMM, yyyy");
            if (imgHandler.Image.Width > imgHandler.Image.Height)
            {
                info.GlobalScale = 340 / (float)imgHandler.Image.Height;
            }
            else
            {
                info.GlobalScale = 340 / (float)imgHandler.Image.Width;
            }

            return(info);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            //创建缩略图,定义一个小的画布,将图片画到画布上,最后保存。 案例二

            //拿到文件的物理路径
            string filePath = context.Request.MapPath("/ImageUpload/" + "001.jpg");
            //固定尺寸的缩略图
            //using (Bitmap bitmap=new Bitmap(50,50))
            //{
            //    using (Image image=Image.FromFile(filePath))
            //    {
            //        using (Graphics graphics=Graphics.FromImage(bitmap))
            //        {
            //            graphics.DrawImage(bitmap,0,0,bitmap.Width, bitmap.Height);
            //            string fileName = Guid.NewGuid().ToString();
            //            bitmap.Save(context.Request.MapPath("/ImageUpload/" + fileName + ".jpg"),
            //                System.Drawing.Imaging.ImageFormat.Jpeg);
            //        }
            //    }
            //}

            //等比的缩略图
            string thumb     = "/ImageUpload/" + Guid.NewGuid().ToString() + ".jpg";
            string thumbPath = context.Request.MapPath(thumb);

            ImageClass.MakeThumbnail(filePath, thumbPath, 50, 50, "W");
        }
예제 #20
0
        private void buttonCompanySave_Click(object sender, EventArgs e)
        {
            Validate();
            ((Company)companyBindingSource.Current).CompanyId = CheckCompanyId();
            if (companyLogo1PictureBox.Image != null)
            {
                ((Company)companyBindingSource.Current).CompanyLogo1 = ImageClass.ImageToByte(companyLogo1PictureBox.Image);
            }
            if (companyLogo2PictureBox.Image != null)
            {
                ((Company)companyBindingSource.Current).CompanyLogo2 = ImageClass.ImageToByte(companyLogo2PictureBox.Image);
            }
            companyBindingSource.EndEdit();
            var iResult = CompanyManager.Save((Company)companyBindingSource.Current);

            if (iResult > 0)
            {
                MessageBox.Show(@"Company Information saved successfully", @"Save", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(@"Error in saving company information", @"Save", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            companyNameTextBox.Focus();
        }
예제 #21
0
        private void createSupplier()
        {
            bool   Status        = false;
            string StatusDetails = null;

            ModelClass.ModelPOS.ModelSupplier mp = new ModelClass.ModelPOS.ModelSupplier()
            {
                SupplierName     = textBoxName.Text,
                SupplierPhoneNo  = textBoxPhone.Text,
                SupplierMobileNo = textBoxMobile.Text,
                SupplierAddress  = textBoxAddress.Text,
            };

            string Photo = ImageClass.GetBase64StringFromImage(Imager.Resize(pictureBoxSupplier.Image, 200, 200, true)); //Resize & Convert to String

            mp.SupplierPicture = Photo;
            MainClass.POS.CRUDSuppierCreate(mp, out Status, out StatusDetails);
            if (Status)
            {
                JIMessageBox.InformationMessage(StatusDetails);
                clearTextbox();
            }
            else
            {
                MessageBox.Show(StatusDetails, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            gridViewSupplier.Rows.Clear();
        }
예제 #22
0
    /// <summary>
    /// Чтение в переменную обьекта класса Comment.
    /// </summary>
    /// <param name="PeopleID"></param>
    public void ReadeImageIDsOfPeople(int PeopleID)
    {
        ImageIDsOfPeople = new List <int>();
        ImageClass oImage = new ImageClass();

        oImage.readeImageIDs(PeopleID, ImageIDsOfPeople);
        this.IDcounter = 0;
    }
예제 #23
0
        public void RotateImage(int angle)
        {
            ImageClass imgClass = new ImageClass();

            Img.Img           = (Bitmap)imgClass.GetRotateImage(imgInfo.Img, angle);
            pictureBox1.Image = Img.Img;
            pictureBox1.Invalidate();
        }
예제 #24
0
        public IActionResult UploadImg()
        {
            var ic       = new ImageClass();
            var fileInfo = AccessWWWRoot();

            ic.FileImages = fileInfo;
            return(View(ic));
        }
예제 #25
0
        public ActionResult UpImage(HttpPostedFileBase file, int width, int height, string mode, int sk = 0)
        {
            // 没有文件上传,直接返回
            if (file == null || string.IsNullOrEmpty(file.FileName) || file.ContentLength == 0)
            {
                return(HttpNotFound());
            }

            //获取文件完整文件名(包含绝对路径)
            //文件存放路径格式:/files/upload/{日期}/{Guid+文件名}.{后缀名}
            //例如:/files/upload/20130913/43CA215D947F8C1F1DDFCED383C4D706.jpg
            //string str = Filedata.FileName.Substring(0, Filedata.FileName.LastIndexOf('.'));
            string fileName       = Guid.NewGuid().ToString("N");
            string fileEextension = Path.GetExtension(file.FileName);
            string uploadDate     = DateTime.Now.ToString("yyyyMMdd");

            if (file.ContentType.Contains("image"))
            {
                var virtualOriginalPath = string.Format("~/UploadFiles/images/{0}/Original/{1}{2}", uploadDate, fileName,
                                                        fileEextension);//原图片路径

                var virtualThumbnailPath = string.Format("~/UploadFiles/images/{0}/Thumbnail/{1}{2}", uploadDate, fileName,
                                                         fileEextension);//缩略图路径
                string fullOriginaFileName   = this.Server.MapPath(virtualOriginalPath);
                string fullThumbnailFileName = this.Server.MapPath(virtualThumbnailPath);
                //创建文件夹,保存文件
                string path = Path.GetDirectoryName(fullOriginaFileName);
                if (path != null)
                {
                    Directory.CreateDirectory(path);
                    if (!System.IO.File.Exists(fullOriginaFileName))
                    {
                        file.SaveAs(fullOriginaFileName);
                    }
                }

                path = Path.GetDirectoryName(fullThumbnailFileName);
                if (path != null)
                {
                    Directory.CreateDirectory(path);
                }
                ImageClass.MakeThumbnail(fullOriginaFileName, fullThumbnailFileName, width, height, mode);//生成缩略图
                if (sk != 0)
                {
                    Common.FileOperate.FileDel(fullOriginaFileName);
                }
                dynamic data = new
                {
                    OriginalPath  = virtualOriginalPath.Remove(0, 1),
                    ThumbnailPath = virtualThumbnailPath.Remove(0, 1)
                };
                return(Json(SysEnum.成功, data, "图片上传成功"));
            }
            else
            {
                return(Json(SysEnum.失败, "上传失败,格式错误"));
            }
        }
예제 #26
0
 private void GameChatPlayerFroms_Load(object sender, EventArgs e)
 {
     this.loadContactsOnLoad.Invoke(this, new LoadContactsEventArgs()
     {
         loadContacts = false
     });
     this.ImageClass = new ImageClass();
     DataGridRows();
 }
예제 #27
0
        public ActionResult Update(Machine mach, HttpPostedFileBase picture, string status)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (picture != null)
                    {
                        ImageClass.ImageMethod(picture, "Machine", out string bigImageName, out string smallImageName, out string tempData);

                        if (tempData != null)
                        {
                            TempData["warning"] = tempData;
                        }

                        if (mach.SmallImageName != null)
                        {
                            System.IO.File.Delete(Server.MapPath("~/Uploads/Machine/" + mach.SmallImageName));
                        }
                        if (mach.BigImageName != null)
                        {
                            System.IO.File.Delete(Server.MapPath("~/Uploads/Machine/" + mach.BigImageName));
                        }

                        mach.BigImageName   = bigImageName;
                        mach.SmallImageName = smallImageName;
                    }
                    MachineDao mDao = new MachineDao();
                    UserDao    uDao = new UserDao();

                    mach.Repairman = uDao.GetByLogin(User.Identity.Name);
                    mach.Status    = status;

                    if (mach.Status == "Poškozený")
                    {
                        mach.FaultUser = uDao.GetByLogin(User.Identity.Name);
                        mach.FaultDate = DateTime.Today;
                    }

                    mDao.Update(mach);
                }
                else
                {
                    return(View("Edit", mach));
                }
                if (TempData["warning"] == null)
                {
                    TempData["succes"] = "Úprava stroje " + mach.Name + " proběhla úspěšně.";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(RedirectToAction("Index"));
        }
        private void udmSearchFromBarcode()
        {
            bool   Status        = false;
            string StatusDetails = null;

            try
            {
                mp.BarCode = textBoxSearchBarcode.Text.ToString();

                DataTable dt = MainClass.POS.usp_GetProduct_withoutImage(mp, out Status, out StatusDetails);
                if (Status && dt.Rows.Count > 0)
                {
                    mp.ProductID                   = int.Parse(dt.Rows[0]["ProductID"].ToString());
                    cbCategory.Text                = dt.Rows[0]["CategoryName"].ToString();
                    cbType.Text                    = dt.Rows[0]["ProductType"].ToString();
                    cbBrand.Text                   = dt.Rows[0]["ProductBrand"].ToString();
                    cbSize.Text                    = dt.Rows[0]["ProductSize"].ToString();
                    cbColor.Text                   = dt.Rows[0]["ProductColor"].ToString();
                    textBoxBarcode.Text            = dt.Rows[0]["BarCode"].ToString();
                    textBoxActualPrice.Text        = "";
                    textBoxPurchaseUnitPrice.Text  = "";
                    textBoxQty.Text                = "";
                    textBoxPurchaseTotalPrice.Text = "";
                    DataTable ddt = MainClass.POS.usp_GetProduct_withImage(mp, out Status, out StatusDetails);
                    if (Status)
                    {
                        string pImage = ddt.Rows[0]["ProductPicture"].ToString();
                        if (pImage == "ImageClass.GetImageFromBase64(Row.Cells[ProductPicture].Value.ToString())' threw an exception of type 'System.FormatException" || pImage == "" || pImage == "NoImage")
                        {
                            pictureBoxPurchase.Visible    = false;
                            labelAfterHiddenImage.Visible = true;
                            labelAfterHiddenImage.Text    = "NoImage";
                        }
                        else
                        {
                            pictureBoxPurchase.Visible    = true;
                            labelAfterHiddenImage.Visible = false;
                            pictureBoxPurchase.Image      = ImageClass.GetImageFromBase64(ddt.Rows[0]["ProductPicture"].ToString());
                        }
                        udmGetQtySumFromGridViewDown();
                    }
                    else
                    {
                        MessageBox.Show(StatusDetails, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    JIMessageBox.InformationMessage("Invalid Barcode !");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #29
0
        public string uploadItemImage(System.Web.UI.HtmlControls.HtmlInputFile uploadFiles)
        {
            JObject data = new JObject();

            data["add_by"] = CurrentUser.UserId;
            string dish_id = Request.Params["item_id"];
            //string type = Request.Params["t"];

            string p = Server.MapPath("/");

            p = p + "\\upload\\s" + CurrentUser.DepartmentID.ToString() + "\\" + dish_id + "\\";
            string tmpFile = "";

            if (!System.IO.Directory.Exists(p))
            {
                System.IO.Directory.CreateDirectory(p);
            }
            string thumbP = "";

            for (int i = 0; i <= Request.Files.Count - 1; i++)
            {
                if (Request.Files[i].FileName.Trim().Length > 0)
                {
                    string n = Request.Files[i].FileName.Substring(Request.Files[i].FileName.LastIndexOf("\\") + 1);

                    DateTime now = DateTime.Now;
                    DateTime old = new DateTime(2017, 6, 28);
                    TimeSpan ts  = now - old;
                    int      s   = (int)ts.TotalSeconds;
                    Random   r   = new Random();

                    string ext = n.Substring(n.IndexOf("."));
                    n       = s.ToString() + "_" + r.Next(100).ToString() + ext;
                    tmpFile = n;// +"," + tmpFile;
                    Request.Files[i].SaveAs(p + "\\" + n);
                    thumbP = p + "\\thumb\\";
                    if (!System.IO.Directory.Exists(thumbP))
                    {
                        System.IO.Directory.CreateDirectory(thumbP);
                    }
                    ImageClass ic = new ImageClass(p + "\\" + n);
                    ic.GetReducedImage(80, 80, thumbP + "\\" + n);
                }
            }


            // data["image_path"] = tmpFile;
            data["url"]          = "/upload/s" + CurrentUser.DepartmentID.ToString() + "/" + dish_id + "/" + tmpFile;
            data["default_flag"] = 0;
            data["url_thumb"]    = "/upload/s" + CurrentUser.DepartmentID.ToString() + "/" + dish_id + "/thumb/" + tmpFile;;

            runProc(data);


            return(tmpFile);
        }
예제 #30
0
        public void RotateImage(int angle)
        {
            ImageClass imgClass = new ImageClass();

            Img.Img            = (Bitmap)imgClass.GetRotateImage(Img.Img, angle);
            pictureBox1.Width  = Img.Img.Width;
            pictureBox1.Height = Img.Img.Height;
            pictureBox1.Image  = Img.Img;
            pictureBox1.Invalidate();
        }
예제 #31
0
        public IActionResult Index()
        {
            ImageClass    ic           = new ImageClass();
            var           displayImage = Path.Combine(_iweb.WebRootPath, "images");
            DirectoryInfo di           = new DirectoryInfo(displayImage);

            FileInfo[] fileInfo = di.GetFiles();
            ic.FileImage = fileInfo;
            return(View(ic));
        }
예제 #32
0
파일: TextureUtil.cs 프로젝트: zcrrr/3D2016
    // Use this for initialization
    void Start()
    {
        Main.initById (43);
        myCamera = GetComponent<Camera>();
        string[] spots = Main.testdataPoi.Split (new char[] { ';' });
        for (int i = 0; i < spots.Length; i++) {
            string[] oneSpot = spots[i].Split(new char[] { ',' });
            float lon = float.Parse(oneSpot[0]);
            float lat = float.Parse(oneSpot[1]);
            string name = oneSpot[2];
            float labelLength = name.Length * 30;
            int type = int.Parse(oneSpot[3]);
            int ishot = int.Parse(oneSpot[4]);
            int level = int.Parse(oneSpot[5]);
            PoiClass poi = new PoiClass(lon,lat,name,type,ishot,level,0,1,labelLength);
            list_display.Add(poi);
        }
        for (int i = 1; i<=24; i++) {
            Texture2D image_big = (Texture2D)Resources.Load ("map_"+i+"@3x");
            GUIContent content_big = new GUIContent ();
            content_big.image = image_big;
            texture_big.Add(content_big);

            Texture2D image_small = (Texture2D)Resources.Load ("map_icon_"+i);
            GUIContent content_small = new GUIContent ();
            content_small.image = image_small;
            texture_small.Add(content_small);
        }
        for (int i=4; i<=Main.ImageCount; i++) {
            Texture2D image = (Texture2D)Resources.Load ("1.1-" + i);
            texture_image.Add (image);
            GUIContent content = new GUIContent ();
            content.image = image;
            listImageContent.Add(content);
        }
        if (Main.imgString.Length > 0) {
            string[] images = Main.imgString.Split (new char[] { ';' });
            for (int i=0; i<images.Length; i++) {
                string[] image = images [i].Split (new char[] { ',' });
                float x = float.Parse (image [0]);
                float y = float.Parse (image [1]);
                float z = float.Parse (image [2]);
                int index = int.Parse (image [3]);
                float selfscale = float.Parse (image [4]);
                Vector3 worldloc = new Vector3(x,y,z);
                ImageClass imageclass = new ImageClass(worldloc,index,selfscale);
                listImage.Add(imageclass);

            }
        }
    }
예제 #33
0
파일: TextureUtil.cs 프로젝트: zcrrr/3D2016
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp (KeyCode.X)) {
            transform.Translate (Vector3.forward * stepInt);
        }
        if (Input.GetKeyUp (KeyCode.Z)) {
            transform.Translate (-Vector3.forward * stepInt);
        }
        if (Input.GetKeyUp (KeyCode.LeftArrow)) {
            transform.Translate (Vector3.left * stepInt);
        }
        if (Input.GetKeyUp (KeyCode.RightArrow)) {
            transform.Translate (-Vector3.left * stepInt);
        }
        if (Input.GetKeyUp (KeyCode.UpArrow)) {
            transform.Translate (Vector3.up * stepInt);
        }
        if (Input.GetKeyUp (KeyCode.DownArrow)) {
            transform.Translate (-Vector3.up * stepInt);
        }
        if (Input.GetKeyUp (KeyCode.A)) {
            transform.Translate (Vector3.left * stepIntSmall);
        }
        if (Input.GetKeyUp (KeyCode.D)) {
            transform.Translate (-Vector3.left * stepIntSmall);
        }
        if (Input.GetKeyUp (KeyCode.W)) {
            transform.Translate (Vector3.up * stepIntSmall);
        }
        if (Input.GetKeyUp (KeyCode.S)) {
            transform.Translate (-Vector3.up * stepIntSmall);
        }
        if (Input.GetKeyUp (KeyCode.Q)) {
            if(listImage.Count > 0){
                listImage.RemoveAt(listImage.Count-1);
            }
        }

        //		if (Input.GetKeyUp (KeyCode.Escape))
        //		{
        //			adding = false;
        //			statedes = "正常点击";
        //		}
        if (Input.GetKeyUp (KeyCode.F1))
        {
            if(displayIndex){
                displayIndex = false;
            }else{
                displayIndex = true;
            }
        }
        if (Input.GetKeyUp (KeyCode.F2))
        {
            if(displayPoi){
                displayPoi = false;
            }else{
                displayPoi = true;
            }
        }
        if(Input.GetMouseButtonDown(0)){ //a coordinate of screen (left down corner is 0,0 and right up corner is maxWidth,maxHeight)
            float x = Input.mousePosition.x;//get x of coordinate
            float y = Input.mousePosition.y;//get y of coordinate
            print("x:"+x+"  y:"+y);
            if(y < Screen.height - 240){
                Vector3 locationWorld = myCamera.ScreenToWorldPoint(new Vector3(x,y,transform.position.y/Mathf.Sin(DegreetoRadians(transform.eulerAngles.x))));
                //			print("locationWorld:"+locationWorld);
                locationWorld.y = 0;
                ImageClass image = new ImageClass(locationWorld,selectedButton,float.Parse(userScale));
                listImage.Add(image);
            }

        }
    }