[Libreoffice-commits] libcdr.git: src/lib
Fridrich Å trba
fridrich.strba at bluewin.ch
Wed Feb 27 01:46:23 PST 2013
src/lib/CDRContentCollector.cpp | 26 +++++++++++++++++++++++---
src/lib/CDRTransforms.cpp | 28 ----------------------------
src/lib/CDRTransforms.h | 2 --
src/lib/CDRTypes.h | 8 --------
4 files changed, 23 insertions(+), 41 deletions(-)
New commits:
commit 8fa13903271ef1b7979232fa65b69f4b6320171a
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Feb 27 10:45:59 2013 +0100
Trying to fix rotations, sizes and positions of bitmap objects
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 00c0af4..8dbd4ac 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -328,18 +328,38 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
{
double cx = m_currentImage.getMiddleX();
double cy = m_currentImage.getMiddleY();
+ double corner1x = m_currentImage.m_x1;
+ double corner1y = m_currentImage.m_y1;
+ double corner2x = m_currentImage.m_x1;
+ double corner2y = m_currentImage.m_y2;
+ double corner3x = m_currentImage.m_x2;
+ double corner3y = m_currentImage.m_y2;
m_currentTransforms.applyToPoint(cx, cy);
+ m_currentTransforms.applyToPoint(corner1x, corner1y);
+ m_currentTransforms.applyToPoint(corner2x, corner2y);
+ m_currentTransforms.applyToPoint(corner3x, corner3y);
if (!m_groupTransforms.empty())
+ {
m_groupTransforms.top().applyToPoint(cx, cy);
+ m_groupTransforms.top().applyToPoint(corner1x, corner1y);
+ m_groupTransforms.top().applyToPoint(corner2x, corner2y);
+ m_groupTransforms.top().applyToPoint(corner3x, corner3y);
+ }
CDRTransform tmpTrafo(1.0, 0.0, -m_page.offsetX, 0.0, 1.0, -m_page.offsetY);
tmpTrafo.applyToPoint(cx, cy);
+ tmpTrafo.applyToPoint(corner1x, corner1y);
+ tmpTrafo.applyToPoint(corner2x, corner2y);
+ tmpTrafo.applyToPoint(corner3x, corner3y);
tmpTrafo = CDRTransform(1.0, 0.0, 0.0, 0.0, -1.0, m_page.height);
tmpTrafo.applyToPoint(cx, cy);
+ tmpTrafo.applyToPoint(corner1x, corner1y);
+ tmpTrafo.applyToPoint(corner2x, corner2y);
+ tmpTrafo.applyToPoint(corner3x, corner3y);
bool flipX(m_currentTransforms.getFlipX());
bool flipY(m_currentTransforms.getFlipY());
- double width = m_currentTransforms.getScaleX() * m_currentImage.getWidth();
- double height = m_currentTransforms.getScaleY() * m_currentImage.getHeight();
- double rotate = m_currentTransforms.getRotation();
+ double width = sqrt((corner2x - corner3x)*(corner2x - corner3x) + (corner2y - corner3y)*(corner2y - corner3y));
+ double height = sqrt((corner2x - corner1x)*(corner2x - corner1x) + (corner2y - corner1y)*(corner2y - corner1y));
+ double rotate = atan2(corner3y-corner2y, corner3x-corner2x);
WPXPropertyList propList;
diff --git a/src/lib/CDRTransforms.cpp b/src/lib/CDRTransforms.cpp
index 5451b9b..5876664 100644
--- a/src/lib/CDRTransforms.cpp
+++ b/src/lib/CDRTransforms.cpp
@@ -165,20 +165,6 @@ bool libcdr::CDRTransform::getFlipY() const
return (0 > _getScaleY());
}
-double libcdr::CDRTransform::getRotation() const
-{
- double x0 = 0.0;
- double x1 = 1.0;
- double y0 = 0.0;
- double y1 = 0.0;
- applyToPoint(x0, y0);
- applyToPoint(x1, y1);
- double angle = atan2(y1-y0, x1-x0);
- if (angle < 0.0)
- angle += 2*M_PI;
- return angle;
-}
-
double libcdr::CDRTransform::getTranslateX() const
{
double x = 0.0;
@@ -284,20 +270,6 @@ bool libcdr::CDRTransforms::getFlipY() const
return (0 > _getScaleY());
}
-double libcdr::CDRTransforms::getRotation() const
-{
- double x0 = 0.0;
- double x1 = 1.0;
- double y0 = 0.0;
- double y1 = 0.0;
- applyToPoint(x0, y0);
- applyToPoint(x1, y1);
- double angle = atan2(y1-y0, x1-x0);
- if (angle < 0.0)
- angle += 2*M_PI;
- return angle;
-}
-
double libcdr::CDRTransforms::getTranslateX() const
{
double x = 0.0;
diff --git a/src/lib/CDRTransforms.h b/src/lib/CDRTransforms.h
index 9256816..0e96c80 100644
--- a/src/lib/CDRTransforms.h
+++ b/src/lib/CDRTransforms.h
@@ -47,7 +47,6 @@ public:
void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const;
double getScaleX() const;
double getScaleY() const;
- double getRotation() const;
double getTranslateX() const;
double getTranslateY() const;
bool getFlipX() const;
@@ -80,7 +79,6 @@ public:
void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const;
double getScaleX() const;
double getScaleY() const;
- double getRotation() const;
double getTranslateX() const;
double getTranslateY() const;
bool getFlipX() const;
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index a87d012..aeb2e87 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -203,14 +203,6 @@ struct CDRImage
{
return (m_y1 + m_y2) / 2.0;
}
- double getWidth() const
- {
- return fabs(m_x1 - m_x2);
- }
- double getHeight() const
- {
- return fabs(m_y1 - m_y2);
- }
const WPXBinaryData &getImage() const
{
return m_image;
More information about the Libreoffice-commits
mailing list