Produced by Araxis Merge on 10/26/2017 10:44:23 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Oct 27 02:44:23 2017 UTC | ||
| 2 | OSCIF_BMS_v2_iter 2_September_2017.zip\BMS_Cand\Source\Sources\BMS.Vista.TestEis\BMS.Utils | ImageConverter.cs | Wed Oct 18 18:47:02 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 160 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | using Syst em; | |||||
| 2 | using Syst em.Collect ions.Gener ic; | |||||
| 3 | using Syst em.Linq; | |||||
| 4 | using Syst em.Text; | |||||
| 5 | using Syst em.IO; | |||||
| 6 | using Syst em.Drawing ; | |||||
| 7 | using Syst em.Drawing .Imaging; | |||||
| 8 | using Syst em.Web; | |||||
| 9 | ||||||
| 10 | namespace BMS.Utils | |||||
| 11 | { | |||||
| 12 | /// <s ummary> | |||||
| 13 | /// Im age Conver ter class | |||||
| 14 | /// </ summary> | |||||
| 15 | public static cl ass ImageC onverter | |||||
| 16 | { | |||||
| 17 | // / <summary > | |||||
| 18 | // / Convert Image to b yte[] arra y | |||||
| 19 | // / </summar y> | |||||
| 20 | // / <param n ame="image ">The imag e</param> | |||||
| 21 | // / <returns ></returns > | |||||
| 22 | pu blic stati c byte[] G etByteArra yFromImage (Image ima ge) | |||||
| 23 | { | |||||
| 24 | DateTime entryInLo gMethodTim e = DateTi me.UtcNow; | |||||
| 25 | if (Info World.Trac ing.IWTrac e.IsEntryE nabled) | |||||
| 26 | { | |||||
| 27 | Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime); | |||||
| 28 | } | |||||
| 29 | try | |||||
| 30 | { | |||||
| 31 | byte [] imageBy tes; | |||||
| 32 | usin g (MemoryS tream ms = new Memor yStream()) | |||||
| 33 | { | |||||
| 34 | image.Save (ms, Syste m.Drawing. Imaging.Im ageFormat. Png); | |||||
| 35 | image.Disp ose(); | |||||
| 36 | imageBytes = ms.ToAr ray(); | |||||
| 37 | } | |||||
| 38 | retu rn imageBy tes; | |||||
| 39 | } | |||||
| 40 | finally | |||||
| 41 | { | |||||
| 42 | if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled) | |||||
| 43 | { | |||||
| 44 | InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(), DateTime.U tcNow, ent ryInLogMet hodTime); | |||||
| 45 | } | |||||
| 46 | } | |||||
| 47 | } | |||||
| 48 | ||||||
| 49 | // / <summary > | |||||
| 50 | // / Convert Image to b yte[] arra y | |||||
| 51 | // / </summar y> | |||||
| 52 | // / <param n ame="image ">The imag e</param> | |||||
| 53 | // / <returns ></returns > | |||||
| 54 | pu blic stati c void Get ImageFromB yteArray(s tring byte Array, str ing imageN ame) | |||||
| 55 | { | |||||
| 56 | DateTime entryInLo gMethodTim e = DateTi me.UtcNow; | |||||
| 57 | if (Info World.Trac ing.IWTrac e.IsEntryE nabled) | |||||
| 58 | { | |||||
| 59 | Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime); | |||||
| 60 | } | |||||
| 61 | try | |||||
| 62 | { | |||||
| 63 | stri ng folderP ath = Http Context.Cu rrent.Serv er.MapPath ("~/Conten t/images/E VS/"); | |||||
| 64 | if ( !Directory .Exists(fo lderPath)) | |||||
| 65 | Directory. CreateDire ctory(fold erPath); | |||||
| 66 | stri ng imgPath = Path.Co mbine(fold erPath, im ageName); | |||||
| 67 | if ( !File.Exis ts(imgPath )) | |||||
| 68 | { | |||||
| 69 | byte[] ima geBytes = Convert.Fr omBase64St ring(byteA rray); | |||||
| 70 | MemoryStre am ms = ne w MemorySt ream(image Bytes, 0, imageBytes .Length); | |||||
| 71 | ms.Write(i mageBytes, 0, imageB ytes.Lengt h); | |||||
| 72 | Image imag e = Image. FromStream (ms, true) ; | |||||
| 73 | image.Save (imgPath, ImageForma t.Png); | |||||
| 74 | ms.Close() ; | |||||
| 75 | image.Disp ose(); | |||||
| 76 | } | |||||
| 77 | } | |||||
| 78 | finally | |||||
| 79 | { | |||||
| 80 | if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled) | |||||
| 81 | { | |||||
| 82 | InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(), DateTime.U tcNow, ent ryInLogMet hodTime); | |||||
| 83 | } | |||||
| 84 | } | |||||
| 85 | } | |||||
| 86 | ||||||
| 87 | pu blic stati c string G etImageRel ativePath( ) | |||||
| 88 | { | |||||
| 89 | DateTime entryInLo gMethodTim e = DateTi me.UtcNow; | |||||
| 90 | if (Info World.Trac ing.IWTrac e.IsEntryE nabled) | |||||
| 91 | { | |||||
| 92 | Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime); | |||||
| 93 | } | |||||
| 94 | try | |||||
| 95 | { | |||||
| 96 | stri ng url = H ttpContext .Current.R equest.Url .AbsoluteP ath; | |||||
| 97 | int count = ur l.Count(a => a.Equal s('/')); | |||||
| 98 | Stri ngBuilder path = new StringBui lder(); | |||||
| 99 | for (int i = 1 ; i <= cou nt; i++) | |||||
| 100 | path.Appen d("../"); | |||||
| 101 | path .Append("C ontent/ima ges/EVS/") ; | |||||
| 102 | retu rn path.To String(); | |||||
| 103 | } | |||||
| 104 | finally | |||||
| 105 | { | |||||
| 106 | if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled) | |||||
| 107 | { | |||||
| 108 | InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(), DateTime.U tcNow, ent ryInLogMet hodTime); | |||||
| 109 | } | |||||
| 110 | } | |||||
| 111 | } | |||||
| 112 | ||||||
| 113 | pu blic stati c byte[] M ergeMultip leImages(L ist<string > imagesBy tes) | |||||
| 114 | { | |||||
| 115 | DateTime entryInLo gMethodTim e = DateTi me.UtcNow; | |||||
| 116 | if (Info World.Trac ing.IWTrac e.IsEntryE nabled) | |||||
| 117 | { | |||||
| 118 | Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime); | |||||
| 119 | } | |||||
| 120 | try | |||||
| 121 | { | |||||
| 122 | byte [] result; | |||||
| 123 | if ( imagesByte s.Count == 1) | |||||
| 124 | result = C onvert.Fro mBase64Str ing(images Bytes[0]); | |||||
| 125 | else | |||||
| 126 | { | |||||
| 127 | int count = 0; | |||||
| 128 | using (Bit map bitmap = new Bit map(20 * i magesBytes .Count, 20 )) | |||||
| 129 | { | |||||
| 130 | Graphi cs g = Gra phics.From Image(bitm ap); | |||||
| 131 | foreac h (string icon in im agesBytes) | |||||
| 132 | { | |||||
| 133 | by te[] image Bytes = Co nvert.From Base64Stri ng(icon); | |||||
| 134 | Me moryStream ms = new MemoryStre am(imageBy tes, 0, im ageBytes.L ength); | |||||
| 135 | ms .Write(ima geBytes, 0 , imageByt es.Length) ; | |||||
| 136 | Im age image = Image.Fr omStream(m s, true); | |||||
| 137 | ms .Close(); | |||||
| 138 | g. DrawImage( image, 20 * count, 0 ); | |||||
| 139 | im age.Dispos e(); | |||||
| 140 | co unt++; | |||||
| 141 | } | |||||
| 142 | ||||||
| 143 | Memory Stream msB yte = new MemoryStre am(); | |||||
| 144 | bitmap .Save(msBy te, System .Drawing.I maging.Ima geFormat.P ng); | |||||
| 145 | result = msByte. ToArray(); | |||||
| 146 | msByte .Close(); | |||||
| 147 | } | |||||
| 148 | } | |||||
| 149 | retu rn result; | |||||
| 150 | } | |||||
| 151 | finally | |||||
| 152 | { | |||||
| 153 | if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled) | |||||
| 154 | { | |||||
| 155 | InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(), DateTime.U tcNow, ent ryInLogMet hodTime); | |||||
| 156 | } | |||||
| 157 | } | |||||
| 158 | } | |||||
| 159 | } | |||||
| 160 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.