{"id":26821,"date":"2021-03-22T12:30:28","date_gmt":"2021-03-22T11:30:28","guid":{"rendered":"https:\/\/help.qualiware.it\/qw-help\/?p=26821"},"modified":"2021-03-22T12:30:28","modified_gmt":"2021-03-22T11:30:28","slug":"modifica-della-risoluzione-di-unimmagine","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/modifica-della-risoluzione-di-unimmagine\/","title":{"rendered":"Modifica della risoluzione di un&#8217;immagine"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente snippet pu\u00f2 essere utilizzato nell'EventoEsegui di un oggetto Procedura specificato come oggetto di ritorno del metodo UploadFile() per abbassare la risoluzione di un'immagine caricata\r\ntry                         \r\n                dim tmpBase64String as string = ImageToBase64(Parameter1)\r\n                Dim Base64String As String, NEW_Base64String As String\r\n                \r\n                if dbdollar(\"data:image\", tmpBase64String) or dbdollar(\";base64,\", tmpBase64String)\r\n                               Base64String = Substr(tmpBase64String, 23, Len(tmpBase64String))\r\n                else\r\n                               Base64String = tmpBase64String\r\n                end if\r\n                \r\n                Dim ConvertBase64ToByteArray As Byte()\r\n                Dim ms As System.IO.MemoryStream\r\n                Dim image As System.Drawing.Image\r\n                \r\n                ConvertBase64ToByteArray = Convert.FromBase64String(Base64String)\r\n                ms = New System.IO.MemoryStream(ConvertBase64ToByteArray)\r\n                image = System.Drawing.Image.FromStream(ms)\r\n                \r\n                Dim width As Integer = image.Width ' Vengono mantenute le dimensioni dell'immagine caricata\r\n                Dim height As Integer = image.Height\r\n                \r\n                Dim bm As Drawing.Bitmap = New System.Drawing.Bitmap(width, height)\r\n                Dim g As System.Drawing.Graphics = Drawing.Graphics.FromImage(bm)\r\n                \r\n                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low ' Qui viene specificato di abbassare la risoluione\r\n                g.DrawImage(image, 0, 0, width, height)\r\n                Dim imgOutput As System.Drawing.Image = bm\r\n                \r\n                Dim m As System.IO.MemoryStream = New System.IO.MemoryStream()\r\n                imgOutput.Save(m, image.RawFormat)\r\n                Dim imageBytes As Byte() = m.ToArray()\r\n                NEW_Base64String = Convert.ToBase64String(imageBytes)\r\n                \r\n                dim n as integer = form.findcontrol(\"FOTO\").Count() + 1\r\n                \r\n                ' La foto viene ricaricata su una griglia, ma pu\u00f2 essere gestita anche diversamente\r\n                form.findcontrol(\"FOTO\").AddRow()\r\n                form.findcontrol(\"FOTO\").AssignField(\"NUMBER1\", n)\r\n                form.findcontrol(\"FOTO\").AssignField(\"CUSTOM15\", NEW_Base64String)\r\n                form.findcontrol(\"FOTO\").SaveRow()\r\ncatch e as system.exception\r\n                WriteLog(\"Errore nell'elaborazione dell'immagine: \" + vbnewline + \"xxx ERRORE xxx \" + vbnewline + \"Errore: \" + vbnewline + e.Message + vbNewLine + \"--- Stack --- \" + vbNewLine + e.StackTrace)\r\n                form.Alert(\"Si \u00e8 verificato un ERRORE imprevisto!\" + vbnewline + \"Contattare l'Assistenza Tecnica QualiWare.\" + vbnewline + \"Il Dettaglio dell'Errore si trova nel File di Log.\")\r\nend try\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216; Il seguente snippet pu\u00f2 essere utilizzato nell&#8217;EventoEsegui di un oggetto Procedura specificato come oggetto di ritorno del metodo UploadFile() per abbassare la risoluzione di un&#8217;immagine caricata try dim tmpBase64String as string = ImageToBase64(Parameter1) Dim Base64String As String, NEW_Base64String As String if dbdollar(&#8220;data:image&#8221;, tmpBase64String) or dbdollar(&#8220;;base64,&#8221;, tmpBase64String) Base64String = Substr(tmpBase64String, 23, Len(tmpBase64String)) else Base64String =&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[71],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26821"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=26821"}],"version-history":[{"count":0,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26821\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=26821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=26821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=26821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}