Преглед изворни кода

get/set image size (inches) helper

master
Lorenzo Delana пре 8 година
родитељ
комит
ff4c29eb87
1 измењених фајлова са 38 додато и 2 уклоњено
  1. 38
    2
      DocX/Picture.cs

+ 38
- 2
DocX/Picture.cs Прегледај датотеку

@@ -338,7 +338,7 @@ namespace Novacode
{
return img.FileName;
}
}
}
/// <summary>
/// Get or sets the Width of this Image.
@@ -372,11 +372,47 @@ namespace Novacode
}
}
// refs:
// https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/
// http://lcorneliussen.de/raw/dashboards/ooxml/
private const int InchToEmuFactor = 914400;
private const double EmuToInchFactor = 1d / InchToEmuFactor;
/// <summary>
/// Get or sets the Width of this Image (inches).
/// </summary>
public double WidthInches
{
get
{
return Width * EmusInPixel * EmuToInchFactor;
}
set
{
Width = (int)(value * InchToEmuFactor / EmusInPixel);
}
}
/// <summary>
/// Get or sets the Height of this Image (inches).
/// </summary>
public double HeightInches
{
get
{
return Height * EmusInPixel * EmuToInchFactor;
}
set
{
Height = (int)(value * InchToEmuFactor / EmusInPixel);
}
}
//public void Delete()
//{
// // Remove xml
// i.Remove();
// // Rebuild the image collection for this paragraph
// // Requires that every Image have a link to its paragraph

Loading…
Откажи
Сачувај