Explorar el Código

get/set image size (inches) helper

master
Lorenzo Delana hace 8 años
padre
commit
ff4c29eb87
Se han modificado 1 ficheros con 38 adiciones y 2 borrados
  1. 38
    2
      DocX/Picture.cs

+ 38
- 2
DocX/Picture.cs Ver fichero

@@ -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

Cargando…
Cancelar
Guardar