1 // xImaLyr.cpp : Layers functions
\r
2 /* 21/04/2003 v1.00 - Davide Pizzolato - www.xdp.it
\r
3 * CxImage version 6.0.0 02/Feb/2008
\r
8 #if CXIMAGE_SUPPORT_LAYERS
\r
10 ////////////////////////////////////////////////////////////////////////////////
\r
12 * If the object is an internal layer, GetParent return its parent in the hierarchy.
\r
14 CxImage* CxImage::GetParent() const
\r
16 return info.pParent;
\r
18 ////////////////////////////////////////////////////////////////////////////////
\r
20 * Number of layers allocated directly by the object.
\r
22 long CxImage::GetNumLayers() const
\r
24 return info.nNumLayers;
\r
26 ////////////////////////////////////////////////////////////////////////////////
\r
28 * Creates an empty layer. If position is less than 0, the new layer will be placed in the last position
\r
30 bool CxImage::LayerCreate(long position)
\r
32 if ( position < 0 || position > info.nNumLayers ) position = info.nNumLayers;
\r
34 CxImage** ptmp = new CxImage*[info.nNumLayers + 1];
\r
35 if (ptmp==0) return false;
\r
38 for (int n=0; n<info.nNumLayers; n++){
\r
40 ptmp[n] = new CxImage();
\r
43 ptmp[n+i]=ppLayers[n];
\r
45 if (i==0) ptmp[info.nNumLayers] = new CxImage();
\r
47 if (ptmp[position]){
\r
48 ptmp[position]->info.pParent = this;
\r
59 ////////////////////////////////////////////////////////////////////////////////
\r
61 * Deletes a layer. If position is less than 0, the last layer will be deleted
\r
63 bool CxImage::LayerDelete(long position)
\r
65 if ( position >= info.nNumLayers ) return false;
\r
66 if ( position < 0) position = info.nNumLayers - 1;
\r
67 if ( position < 0) return false;
\r
69 if (info.nNumLayers>1){
\r
71 CxImage** ptmp = new CxImage*[info.nNumLayers - 1];
\r
72 if (ptmp==0) return false;
\r
75 for (int n=0; n<info.nNumLayers; n++){
\r
80 ptmp[n]=ppLayers[n+i];
\r
91 info.nNumLayers = 0;
\r
95 ////////////////////////////////////////////////////////////////////////////////
\r
96 void CxImage::LayerDeleteAll()
\r
99 for(long n=0; n<info.nNumLayers;n++){ delete ppLayers[n]; }
\r
100 delete [] ppLayers; ppLayers=0; info.nNumLayers = 0;
\r
103 ////////////////////////////////////////////////////////////////////////////////
\r
105 * Returns a pointer to a layer. If position is less than 0, the last layer will be returned
\r
107 CxImage* CxImage::GetLayer(long position)
\r
109 if ( ppLayers == NULL) return NULL;
\r
110 if ( info.nNumLayers == 0) return NULL;
\r
111 if ( position >= info.nNumLayers ) return NULL;
\r
112 if ( position < 0) position = info.nNumLayers - 1;
\r
113 return ppLayers[position];
\r
115 ////////////////////////////////////////////////////////////////////////////////
\r
116 #endif //CXIMAGE_SUPPORT_LAYERS
\r