11namespace MiniSoftware
22{
33 using DocumentFormat . OpenXml ;
4+ using DocumentFormat . OpenXml . Packaging ;
5+ using System ;
6+ using System . Collections . Generic ;
47
58 public class MiniWordPicture
69 {
10+
11+
712 public string Path { get ; set ; }
8- public byte [ ] Bytes { get ; set ; }
9- public Int64Value Width { get ; set ; } = 990000L ;
13+ private string _extension ;
14+ public string Extension
15+ {
16+ get
17+ {
18+ if ( Path != null )
19+ return System . IO . Path . GetExtension ( Path ) . ToUpperInvariant ( ) . Replace ( "." , "" ) ;
20+ else
21+ {
22+ return _extension . ToUpper ( ) ;
23+ }
24+ }
25+ set { _extension = value ; }
26+ }
27+ internal ImagePartType GetImagePartType
28+ {
29+ get
30+ {
31+ switch ( Extension . ToLower ( ) )
32+ {
33+ case "bmp" : return ImagePartType . Bmp ;
34+ case "emf" : return ImagePartType . Emf ;
35+ case "ico" : return ImagePartType . Icon ;
36+ case "jpg" : return ImagePartType . Jpeg ;
37+ case "jpeg" : return ImagePartType . Jpeg ;
38+ case "pcx" : return ImagePartType . Pcx ;
39+ case "png" : return ImagePartType . Png ;
40+ case "svg" : return ImagePartType . Svg ;
41+ case "tiff" : return ImagePartType . Tiff ;
42+ case "wmf" : return ImagePartType . Wmf ;
43+ default :
44+ throw new NotSupportedException ( $ "{ _extension } is not supported") ;
45+ }
46+ }
47+ }
1048
11- public Int64Value Height { get ; set ; } = 792000L ;
12- }
49+ public byte [ ] Bytes { get ; set ; }
50+ /// <summary>
51+ /// Unit is Pixel
52+ /// </summary>
53+ public Int64Value Width { get ; set ; } = 400 ;
54+ internal Int64Value Cx { get { return Width * 9525 ; } }
55+ /// <summary>
56+ /// Unit is Pixel
57+ /// </summary>
58+ public Int64Value Height { get ; set ; } = 400 ;
59+ //format resource from http://openxmltrix.blogspot.com/2011/04/updating-images-in-image-placeholde-and.html
60+ internal Int64Value Cy { get { return Height * 9525 ; } }
61+ }
1362}
0 commit comments