public ProcessImage Convert(ProcessImage source, ProcessImageType target, bool flipHorizontal = false, bool flipVertical = false) { if (source.Type == target) { return(source); } if (source.Type == ProcessImageType.PNG) { return(Encode(SKImage.FromBitmap(SKBitmap.Decode(source.Load)), target, flipHorizontal, flipVertical)); } if (source.Type == ProcessImageType.Grayscale8) { return(Encode(SKImage.FromPixelCopy(new SKImageInfo(source.Width, source.Height, SKColorType.Gray8), source.Load), target, flipHorizontal, flipVertical)); } if (source.Type == ProcessImageType.RGBA8) { return(Encode(SKImage.FromPixelCopy(new SKImageInfo(source.Width, source.Height, SKColorType.Rgba8888), source.Load), target, flipHorizontal, flipVertical)); } if (source.Type == ProcessImageType.RGBA16) { return(Encode(SKImage.FromPixelCopy(new SKImageInfo(source.Width, source.Height, SKColorType.RgbaF16), source.Load), target, flipHorizontal, flipVertical)); } /*if (source.Type == ProcessImageType.RGBA32) * { * Image img = Image.LoadPixelData<RgbaVector>(source.Load, source.Width, source.Height); * if (flipHorizontal) { img.Mutate(x => x.Flip(FlipMode.Horizontal)); } * if (flipVertical) { img.Mutate(x => x.Flip(FlipMode.Vertical)); } * return Encode(img, target); * }*/ throw new FormatException("Format conversion not implemented"); }
private bool ReadFileData(string filename) { // // If PDF and scanning method is image, then PDF needs to be split into separate images for each page // These individual pages then need to be scanned in using the Acusoft toolset (Syncfusion does not support images, only PDF image source files) //// Splid PDF into pages ////if (Path.GetExtension(fileStatus.fileName).ToLower() == ".pdf") ////{ //// // Process PDF file ready for scanning - split pages and export multiple .jpg. //// // This is currently dummy code, not yet implimented. See samples from Syncfusion on how to complete, if required //// var zz = ProcessPDF.Main(fileStatus.fileName); ////} ScanPageStatus scanPageStatus = new ScanPageStatus(); ProcessImage processImage = new ProcessImage(); scanPageStatus = processImage.ReadFile(filename); if (scanPageStatus.rc < 0) { logger.Error(scanPageStatus.statusMessage); return(false); } if (scanPageStatus.rc == 0) { logger.Info(scanPageStatus.statusMessage); } else { logger.Warn(scanPageStatus.statusMessage); } return(true); }
private void btnGuess_Click(object sender, RoutedEventArgs e) { if (_singleImage != null && _raidLevel != RaidLevel.Unknown && _gymColor != GymColor.Unknown) { geometryGroepFull.Children.Clear(); geometryGroepCrop.Children.Clear(); var process = new ProcessImage(_raidbossIconData.IconData, _singleImage, _raidLevel, _gymColor); var imageProperty = process.GetImageProperty(); if (imageProperty != null) { _croppedImage = process.GetCroppedImage(imageProperty); RectangleGeometry rg = GenerateRectangleGeometryFull(imageProperty); geometryGroepFull.Children.Add(rg); croppedImg.Source = _croppedImage; croppedImg.Margin = new Thickness(offsetX, 0, offsetX, 0); croppedImg.UpdateLayout(); foreach (var icon in imageProperty.IconsList) { RectangleGeometry rgIcon = GenerateRectangleGeometryCropped(icon, imageProperty.IconsArea); geometryGroepCrop.Children.Add(rgIcon); } } } }
private void btnButtonHover_Click(object sender, EventArgs e) { if (dlgOpen.ShowDialog() == DialogResult.OK) { Resources.Skin.Buttons.ImageHover = ProcessImage.ImageToString(dlgOpen.FileName); Atualiza(); } }
private void btnTabBackColor_Click(object sender, EventArgs e) { if (dlgOpen.ShowDialog() == DialogResult.OK) { Resources.Skin.Containers.TabImageBack = ProcessImage.ImageToString(dlgOpen.FileName); Atualiza(); } }
private void sknButton4_Click(object sender, EventArgs e) { if (dlgOpen.ShowDialog() == DialogResult.OK) { Resources.Skin.Controls.ImageProgressBar = ProcessImage.ImageToString(dlgOpen.FileName); Atualiza(); } }
private void btnImgGroupBox_Click(object sender, EventArgs e) { if (dlgOpen.ShowDialog() == DialogResult.OK) { Resources.Skin.Controls.ImageGroupBok = ProcessImage.ImageToString(dlgOpen.FileName); Atualiza(); } }
protected virtual void OnOnProcessImageHandler(CubeImage cubeimage, string PanoId) { ProcessImage handler = OnProcessImageHandler; if (handler != null) { handler(cubeimage, PanoId); } }
public PathLoader(ProcessImage pLoaderFunction) { mImageFunction = pLoaderFunction; //Convert commands to a path Curves = new List <Polycurve>(); //Immediately triggers loading of all SVG files through the Process SVG function above var loader = new GeneralLoader(ProcessSVG, "svg"); }
public static Model.TcTupian ProcessModelTupian(HttpPostedFile postfile) { var mdtp = new Model.TcTupian(); var resfile = ""; string path = LibFile.rootpath; string filename = ""; string yuanshiname = "";//原始文件名 var sj = DateTime.Now.ToString("yyyyMM"); if (!Directory.Exists(HttpContext.Current.Server.MapPath(path + sj))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path + sj)); } try { path = path + sj + "/"; FileInfo file = new FileInfo(postfile.FileName); string ext = file.Extension; Random rd = new Random(); var randomname = DateTime.Now.ToString("ddHHmmss") + rd.Next(100000, 200000); filename = randomname + ext; yuanshiname = file.Name.Replace(file.Extension, ""); postfile.SaveAs(HttpContext.Current.Server.MapPath(path + "y_" + filename)); ProcessImage p = new ProcessImage(); //0:创建缩略图失败,1:传入的文件格式错误,2:创建成功 int r = p.CreateThumbnail(HttpContext.Current.Server.MapPath(path + "y_" + filename), HttpContext.Current.Server.MapPath(path + filename)); if (r == 2) { } else { try { File.Delete(HttpContext.Current.Server.MapPath(path + "y_" + filename)); } catch { } } if (r == 2) { resfile = sj + "/" + filename; } } catch { } mdtp.Name = yuanshiname; mdtp.Url = resfile; return(mdtp); }
public ProcessImage PngToRgba8(ProcessImage source) { if (source.Type != ProcessImageType.PNG) { throw new FormatException("Process image should be Png"); } SKBitmap bmp = SKBitmap.Decode(source.Load); return(new ProcessImage { Load = bmp.Bytes, Height = bmp.Height, Type = ProcessImageType.RGBA8, Width = bmp.Width }); }
/* * public ProcessImage Encode(Image img, ProcessImageType toType) * { * if (toType == ProcessImageType.JPEG) * { * using MemoryStream ms = new MemoryStream(); * img.SaveAsJpeg(ms); * return new ProcessImage { Load = ms.ToArray(), Height = img.Height, Type = toType, Width = img.Width }; * } * if (toType == ProcessImageType.PNG) * { * using MemoryStream ms = new MemoryStream(); * img.SaveAsPng(ms); * return new ProcessImage { Load = ms.ToArray(), Height = img.Height, Type = toType, Width = img.Width }; * } * * if (toType == ProcessImageType.RGBA8) * { * } * if (toType == ProcessImageType.RGBA32) * { * } * throw new FormatException("Format conversion not implemented"); * }*/ public ProcessImage PngToJpeg(ProcessImage source) { if (source.Type != ProcessImageType.PNG) { throw new FormatException("Process image should be Png"); } SKImage tmp = SKImage.FromBitmap(SKBitmap.Decode(source.Load)); return(new ProcessImage { Load = tmp.Encode(SKEncodedImageFormat.Jpeg, 95).ToArray(), Type = ProcessImageType.JPEG, Width = tmp.Width, Height = tmp.Height }); }
/// <summary> /// postfile 处理 /// </summary> /// <param name="postfile"></param> /// <returns></returns> public static string ProcessTupian(HttpPostedFile postfile) { var resfile = ""; string path = LibFile.rootpath; string filename = ""; var sj = DateTime.Now.ToString("yyyyMM"); if (!Directory.Exists(HttpContext.Current.Server.MapPath(path + sj))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path + sj)); } try { path = path + sj + "/"; FileInfo file = new FileInfo(postfile.FileName); string ext = file.Extension; Random rd = new Random(); var randomname = DateTime.Now.ToString("ddHHmmss") + rd.Next(100000, 200000); filename = randomname + ext; ProcessImage p = new ProcessImage(); //0:创建缩略图失败,1:传入的文件格式错误,2:创建成功 int r = p.CreateThumbnail(postfile, HttpContext.Current.Server.MapPath(path + filename)); if (r == 2) { #region 创建缩略图成功的情况下,在保存原图 postfile.SaveAs(HttpContext.Current.Server.MapPath(path + "y_" + filename)); #endregion 创建缩略图成功的情况下,在保存原图 } else { try { File.Delete(HttpContext.Current.Server.MapPath(path + sj + "/y_" + filename)); } catch { } } if (r == 2) { resfile = sj + "/" + filename; } } catch { } return(resfile); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory factory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Resources")), RequestPath = new PathString("/Resources") }); if (!env.IsDevelopment()) { app.UseSpaStaticFiles(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); ProcessImage.Init(); //configure Logging to console Log.ConfigureLogger(factory); }
public ProcessImage Rgba8ToPng(ProcessImage source, bool flipHorizontal, bool flipVertical) { if (source.Type != ProcessImageType.RGBA8) { throw new FormatException("Process image should be RGBA8"); } using SKImage img = SKImage.FromPixelCopy(new SKImageInfo(source.Width, source.Height, SKColorType.Rgba8888), source.Load); using SKBitmap bmp = new SKBitmap(img.Width, img.Height); using SKCanvas surface = new SKCanvas(bmp); surface.Scale(flipHorizontal ? -1 : 1, flipVertical ? -1 : 1, flipHorizontal ? source.Width / 2f : 0, flipVertical ? source.Height / 2f : 0); surface.DrawImage(img, 0, 0); return(new ProcessImage { Load = SKImage.FromBitmap(bmp).Encode(SKEncodedImageFormat.Png, 99).ToArray(), Height = source.Height, Type = ProcessImageType.PNG, Width = source.Width }); }
public ActionResult Index() { string fullPath = ""; try { var file = Request.Form.Files[0]; var folderName = Path.Combine("Resources"); var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName); if (file.Length > 0) { var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); fullPath = Path.Combine(pathToSave, fileName); var dbPath = Path.Combine(folderName, fileName); using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } var dictresponse = new Dictionary <string, string>(); var alttext = ProcessImage.ExtractText(fullPath); if (alttext.Length > 0) { alttext = "Image may contain the following text: " + alttext; } dictresponse.Add("text", alttext); //clean file ProcessImage.DeleteFile(fullPath); return(Content(JsonConvert.SerializeObject(dictresponse), "application/json")); } else { return(BadRequest()); } } catch (Exception ex) { ProcessImage.DeleteFile(fullPath); return(StatusCode(500, $"Internal server error: {ex}")); } }
public void ExtractTextTest() { ProcessImage.Init(); var imagepath = "OCR/testimage.jpg"; Assert.IsTrue( File.Exists(imagepath), "Deployment failed: {0} did not get deployed.", imagepath ); ProcessImage.GrayScale(imagepath); Assert.IsTrue(true); var text = ProcessImage.ExtractText(imagepath); Assert.IsNotNull(text); Debug.WriteLine(text); }
private bool RunLicensePlateRecognition() { // string folderPath = Server.MapPath(@"~/App_Data/"); string folderPath = @"C:\VDA_FTP"; ImgImport imgImport = new ImgImport(folderPath); ProcessImage processImage = new ProcessImage(); if (imgImport.IsEmpty() || !imgImport.IsJPG()) { return(false); } else { foreach (Mat img in imgImport.LoadImages()) { processImage.Process(img, "C:/Users/vdovn/source/repos/VDSnuff/IOTHub/IOTHubWeb/bin/"); } return(true); } }
public async Task ProcessImageLogicExists() { var file = new FakeFile(); var data = new FakeApiDataEntityHandler <ImageFile>(); var logic = new CoreApiLogicHandler(); var cloud = new FakeCloudHandler(); var model = VisibleData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <ImageFile> >())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <Persist <ImageFile> >())).Returns(model); cloud.Result.Setup(m => m.Execute(It.IsAny <UploadCmd>())) .Returns(ActionConfirm.CreateSuccess("File Uploaded")); var command = new ProcessImage { DataHandler = data, Source = file, CloudHandler = cloud, LogicHandler = logic, CurrentUser = StandardUser, Model = model, LoadType = "test", ExistingId = model.Id }; await command.Execute(); cloud.HasExecuted.Should().BeTrue(); cloud.Result.Verify(s => s.Execute(It.IsAny <UploadCmd>()), Times.AtLeastOnce()); command.Result.Success.Should().BeTrue(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <ImageFile> >()), Times.Once()); data.Result.Verify(s => s.Execute(It.IsAny <Persist <ImageFile> >()), Times.Once()); }
public void ApplyIndicator(ProgressBar bar, Bitmap originalImage, string pathFilesTrain) { var nSalidas = _dataFile.GetOutputsConfiguration(pathFilesTrain + "\\Configuracion.txt"); var nEntradas = _dataFile.GetNInputsConfiguration(pathFilesTrain + "\\Configuracion.txt"); var nCapas = _dataFile.GetNLayersConfiguration(pathFilesTrain + "\\Configuracion.txt"); var nNeuronasCapa = _dataFile.GetNNeruonsLayerConfiguration(pathFilesTrain + "\\Configuracion.txt"); var fActivacionCapas = _dataFile.GetFActivationLayers(pathFilesTrain + "\\Configuracion.txt"); var fActivacionSalida = _dataFile.GetFActivationOutput(pathFilesTrain + "\\Configuracion.txt"); var listaMatrices = new List <double[, ]>(); var listaUmbrales = new List <double[]>(); for (int i = 0; i < ((2 + nCapas) - 1); i++) { listaMatrices.Add(_dataFile.ReadFileToMatrizPesos(pathFilesTrain + "\\W" + i + ".txt")); } for (int i = 0; i < nCapas + 1; i++) { listaUmbrales.Add(_dataFile.ReadFileToVectorUmbral(pathFilesTrain + "\\U" + i + ".txt")); } _processImage = new ProcessImage(originalImage, bar); _processImage.ApplyIndicator(nSalidas, listaMatrices, listaUmbrales, nCapas, nNeuronasCapa, fActivacionCapas, fActivacionSalida); }
public async Task ProcessImageLogicMissing() { var file = new FakeFile() { FileName = "xxxMissingxxx" }; var data = new FakeApiDataEntityHandler <ImageFile>(); var logic = new CoreApiLogicHandler(); var cloud = new FakeCloudHandler(); var model = VisibleData.GetFirst(); var command = new ProcessImage { DataHandler = data, Source = file, CloudHandler = cloud, LogicHandler = logic, CurrentUser = StandardUser, Model = model, LoadType = "test" }; await command.Execute(); cloud.HasExecuted.Should().BeFalse(); cloud.Result.Verify(s => s.Execute(It.IsAny <UploadCmd>()), Times.Never()); command.Result.Success.Should().BeFalse(); data.HasExecuted.Should().BeFalse(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <ImageFile> >()), Times.Never()); data.Result.Verify(s => s.Execute(It.IsAny <Persist <ImageFile> >()), Times.Never()); }
void ReleaseDesignerOutlets() { if (FeatureMap != null) { FeatureMap.Dispose(); FeatureMap = null; } if (GetImage != null) { GetImage.Dispose(); GetImage = null; } if (imageLabel != null) { imageLabel.Dispose(); imageLabel = null; } if (ImageViewer != null) { ImageViewer.Dispose(); ImageViewer = null; } if (messageLabel != null) { messageLabel.Dispose(); messageLabel = null; } if (ProcessImage != null) { ProcessImage.Dispose(); ProcessImage = null; } if (ResetImage != null) { ResetImage.Dispose(); ResetImage = null; } if (Root != null) { Root.Dispose(); Root = null; } if (switchSwitch != null) { switchSwitch.Dispose(); switchSwitch = null; } if (textAperture != null) { textAperture.Dispose(); textAperture = null; } if (textThreshold1 != null) { textThreshold1.Dispose(); textThreshold1 = null; } if (textThreshold2 != null) { textThreshold2.Dispose(); textThreshold2 = null; } }
private void XuLyBe3(int x, int y) { Bitmap bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_5, _ptbCamera.Width, _ptbCamera.Height); //Properties.Resources.bia8_5; int be = 3; // ban o be so 3 Color c = bitmap.GetPixel(x, y); //dung thuat toan quicksort if (c.ToArgb().Equals(Color.Red.ToArgb())) { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_8, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_8; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_9, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_9; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_10, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_10; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { //10 diem _lblScore3.Text = "10"; ChamDiem(10, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } else { //9 diem _lblScore3.Text = "9"; ChamDiem(9, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } else { _lblScore3.Text = "8"; ChamDiem(8, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } else { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_6, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_6; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_7, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_7; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { //7 diem _lblScore3.Text = "7"; ChamDiem(7, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } else { //6 diem _lblScore3.Text = "6"; ChamDiem(6, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } else { //5 diem _lblScore3.Text = "5"; ChamDiem(5, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } } else { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_3, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_3; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_4, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_4; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { //4 diem _lblScore3.Text = "4"; ChamDiem(4, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } else { //3 diem _lblScore3.Text = "3"; ChamDiem(3, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } else { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_1, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_1; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bitmap = ProcessImage.ResizeImage(Properties.Resources.bia8_2, _ptbCamera.Width, _ptbCamera.Height);//Properties.Resources.bia8_2; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { //2 diem _lblScore3.Text = "2"; ChamDiem(2, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } else { //1 diem _lblScore3.Text = "1"; ChamDiem(1, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } else { //0 diem _lblScore3.Text = "0"; ChamDiem(0, ref luotBia3, ref currentMemberBia3, _dtgScore3, _lblName3, _lblScore3, be); } } } }
private void XuLyBe1(int x, int y) { Bitmap bmResize = ProcessImage.ResizeImage(Properties.Resources.bia4_8, _ptbCamera.Width, _ptbCamera.Height); Bitmap bitmap = bmResize; // Properties.Resources.bia4_8; int be = 1; // ban o be so 1 Color c = bitmap.GetPixel(x, y); //dung thuat toan quicksort if (c.ToArgb().Equals(Color.Red.ToArgb())) { bmResize = ProcessImage.ResizeImage(Properties.Resources.bia4_9, _ptbCamera.Width, _ptbCamera.Height); bitmap = bmResize;//Properties.Resources.bia4_9; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bmResize = ProcessImage.ResizeImage(Properties.Resources.bia4_10, _ptbCamera.Width, _ptbCamera.Height); bitmap = bmResize;//Properties.Resources.bia4_10; c = bitmap.GetPixel(x, y); // neu nam o tam 10 thi la 10, khong la 9 if (c.ToArgb().Equals(Color.Red.ToArgb())) { //10 diem _lblScore.Text = "10"; ChamDiem(10, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } else { //9 diem _lblScore.Text = "9"; ChamDiem(9, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } } else { // neu khong nam trong 9 thi la 8 diem //8 diem _lblScore.Text = "8"; ChamDiem(8, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } } else { bmResize = ProcessImage.ResizeImage(Properties.Resources.bia4_6, _ptbCamera.Width, _ptbCamera.Height); bitmap = bmResize;//Properties.Resources.bia4_6; c = bitmap.GetPixel(x, y); if (c.ToArgb().Equals(Color.Red.ToArgb())) { bmResize = ProcessImage.ResizeImage(Properties.Resources.bia4_7, _ptbCamera.Width, _ptbCamera.Height); bitmap = bmResize;//Properties.Resources.bia4_7; c = bitmap.GetPixel(x, y); // neu nam o tam 7 thi la 7, khong la 6 if (c.ToArgb().Equals(Color.Red.ToArgb())) { //7 diem _lblScore.Text = "7"; ChamDiem(7, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } else { //6 diem _lblScore.Text = "6"; ChamDiem(6, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } } else { bmResize = ProcessImage.ResizeImage(Properties.Resources.bia4_5, _ptbCamera.Width, _ptbCamera.Height); bitmap = bmResize;//Properties.Resources.bia4_5; c = bitmap.GetPixel(x, y); //neu nam o trong 5 thi la 5, con o ngoai la truot if (c.ToArgb().Equals(Color.Red.ToArgb())) { //5 diem _lblScore.Text = "5"; ChamDiem(5, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } else { //0 diem _lblScore.Text = "0"; ChamDiem(0, ref luotBia1, ref currentMemberBia1, _dtgScore, _lblName, _lblScore, be); } } } }
public SVGLoader(ProcessImage pLoaderFunction) { mImageFunction = pLoaderFunction; FileFunction = CheckSvg; }
public ImageLoader(ProcessImage pLoaderFunction) { mImageFunction = pLoaderFunction; FileFunction = CheckImage; }
public void Process(string templateName, string fileName, string measured, float operatorValue, float inspectorValue, float sigma) { // first read document in as stream byte[] original = File.ReadAllBytes(templateName); string[] switches = new string[] {}; var template = GetReport(1); Populate(template); using (var stream = new MemoryStream()) { stream.Write(original, 0, original.Length); using (var docx = WordprocessingDocument.Open(stream, true)) { ConvertFieldCodes(docx.MainDocumentPart.Document); foreach (var detail in template.Charts) { var fieldName = (detail.DetailName.ToUpper().StartsWith("CRT") ? detail.DetailName: "CRT_" + detail.DetailName); var dcInfo = BaseProcess.GetColumnInfo(fieldName); if (!GetTableName(template, dcInfo)) { continue; } if (dcInfo.FieldType == FieldType.Chart) { ProcessChart.Process(docx, dcInfo, detail, detail.DetailName); } } foreach (var field in docx.MainDocumentPart.Document.Descendants <SimpleField>()) { var fieldname = BaseProcess.GetFieldName(field, out switches); if (string.IsNullOrEmpty(fieldname)) { continue; } var dcInfo = BaseProcess.GetColumnInfo(fieldname); if (dcInfo.FieldType == FieldType.Chart) { continue; } if (dcInfo.FieldType == FieldType.Table) { if (!GetTableName(template, dcInfo)) { continue; } var table = template.DataSet.Tables[dcInfo.TableNameInDb]; if (dcInfo.FieldType == FieldType.Table) { ProcessTable.Process(docx, dcInfo, table, field, fieldname); } } else if (dcInfo.FieldType == FieldType.Image) { ProcessImage.ShowIndicator(docx, field, measured, operatorValue, inspectorValue, sigma); } } ProcessTable.RemoveEmptyTables(docx); docx.MainDocumentPart.Document.Save(); } stream.Seek(0, SeekOrigin.Begin); byte[] data = stream.ToArray(); File.WriteAllBytes(fileName, data); } }
public void RefreshImage(Bitmap bitmap) { ProcessImage.Image = bitmap; ProcessImage.Refresh(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string path = LibFile.rootpath; HttpPostedFile postfile = Request.Files[0]; string res = "0"; string filename = ""; var sj = DateTime.Now.ToString("yyyyMM"); if (!Directory.Exists(Server.MapPath(path + sj))) { Directory.CreateDirectory(Server.MapPath(path + sj)); } var viewwidth = ""; var viewheight = ""; try { path = path + sj + "/"; FileInfo file = new FileInfo(postfile.FileName); string ext = file.Extension; Random rd = new Random(); var randomname = DateTime.Now.ToString("ddHHmmss") + rd.Next(100000, 200000); filename = randomname + ext; postfile.SaveAs(Server.MapPath(path + "y_" + filename)); ProcessImage p = new ProcessImage(); //0:创建缩略图失败,1:传入的文件格式错误,2:创建成功 int r = p.CreateThumbnail(postfile, Server.MapPath(path + filename)); if (r == 2) { string[] wh = Request.QueryString["wh"].GetString().Split(','); var len = wh.Length; if (len >= 2) { viewwidth = wh[0]; viewheight = wh[1]; for (int i = 0; i + 1 < len; i += 2) { if (wh[i].GetInt() > 0 && wh[i + 1].GetInt() > 0) { r = p.CreateThumbnail(postfile, Server.MapPath(path + wh[i] + wh[i + 1] + "_" + filename), wh[i].GetInt(), wh[i + 1].GetInt(), true); } } } } else { try { File.Delete(Server.MapPath(path + sj + "/y_" + filename)); } catch { } } if (r == 2) { res = "1"; } else { res = "0"; } } catch { Response.Write(res); Response.End(); } //状态(1:成功,0:失败)|文件名称 Response.Write("{res:'" + res + "',rukuname:'" + sj + "/" + filename + "',viewname:'" + LibFile.get_img(sj + "/" + filename, viewwidth, viewheight) + "'}"); Response.End(); } }
public void InitTest() { ProcessImage.Init(); Assert.IsTrue(true); }