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