16#include <render/vqpainter.h>
20VImage::VImage(
VObject *parent,
const TQString &fname ) :
VObject( parent ), m_image( 0L ), m_fname( fname )
23 m_stroke->setType( VStroke::none );
25 m_image =
new TQImage( m_fname );
26 if( m_image->depth() != 32 )
27 *m_image = m_image->convertDepth( 32 );
28 m_image->setAlphaBuffer(
true );
29 *m_image = m_image->swapRGB();
30 *m_image = m_image->mirror(
false,
true );
33VImage::VImage(
const VImage &other ) :
VObject( other )
36 m_image =
new TQImage( *other.m_image );
41 setStroke( *other.
stroke() );
43 setFill( *other.
fill() );
45 m_fname = other.m_fname;
47 m_matrix = other.m_matrix;
56VImage::draw( VPainter *painter,
const KoRect * )
const
68 KoRect bbox = KoRect( 0, 0, m_image->width(), m_image->height() );
69 KoPoint tl = bbox.topLeft().transform( m_matrix );
70 KoPoint tr = bbox.topRight().transform( m_matrix );
71 KoPoint bl = bbox.bottomLeft().transform( m_matrix );
72 KoPoint br = bbox.bottomRight().transform( m_matrix );
74 painter->moveTo( tl );
75 painter->lineTo( tr );
76 painter->lineTo( br );
77 painter->lineTo( bl );
78 painter->lineTo( tl );
80 painter->setRasterOp( TQt::XorROP );
82 painter->setPen( TQt::yellow );
83 painter->setBrush( TQt::NoBrush );
84 painter->strokePath();
91 m_boundingBox = KoRect( 0, 0, m_image->width(), m_image->height() );
93 if( !m_image->isNull() )
94 painter->drawImage( *m_image, m_matrix );
98VImage::transform(
const TQWMatrix& m )
103 kdDebug(38000) <<
"dx : " << m.dx() <<
", dy : " << m.dy() << endl;
110 return new VImage( *
this );
114VImage::save( TQDomElement& element )
const
118 TQDomElement me = element.ownerDocument().createElement(
"IMAGE" );
119 element.appendChild( me );
121 me.setAttribute(
"fname", m_fname );
122 me.setAttribute(
"m11", m_matrix.m11() );
123 me.setAttribute(
"m12", m_matrix.m12() );
124 me.setAttribute(
"m21", m_matrix.m21() );
125 me.setAttribute(
"m22", m_matrix.m22() );
126 me.setAttribute(
"dx", m_matrix.dx() );
127 me.setAttribute(
"dy", m_matrix.dy() );
132VImage::load(
const TQDomElement& element )
135 m_fname = element.attribute(
"fname" );
136 m_matrix.setMatrix( element.attribute(
"m11",
"1.0" ).toDouble(),
137 element.attribute(
"m12",
"0.0" ).toDouble(),
138 element.attribute(
"m21",
"0.0" ).toDouble(),
139 element.attribute(
"m22",
"1.0" ).toDouble(),
140 element.attribute(
"dx",
"0.0" ).toDouble(),
141 element.attribute(
"dy",
"0.0" ).toDouble() );
142 kdDebug(38000) <<
"VImage::load : " << m_fname.latin1() << endl;
144 m_image =
new TQImage( m_fname );
145 if( m_image->depth() != 32 )
146 *m_image = m_image->convertDepth( 32 );
147 m_image->setAlphaBuffer(
true );
148 *m_image = m_image->swapRGB();
149 *m_image = m_image->mirror(
false,
true );
150 m_boundingBox = KoRect( 0, 0, m_image->width(), m_image->height() );
Manages the fill of shapes.
The base class for all karbon objects.
virtual VObject * clone() const =0
Create an exact copy of this object.
virtual void setState(const VState state)
Sets the state to a specified new state.
@ hidden_locked
hidden and locked (r/o)
@ deleted
deleted, nearly dead
@ normal
visible, not active
@ edit
visible, active and is currently manipulated by a tool
virtual VFill * fill() const
Gets the object's actual fill.
KoRect m_boundingBox
the object's bounding box
virtual VStroke * stroke() const
Gets the object's actual stroke.
VState state() const
Get the state the object is in.
Manages stroke properties.
The abstract visitor class.
virtual void visitVImage(VImage &img)
Visit method for a VImage.