Resource_BitmapStrip.cpp
Go to the documentation of this file.00001 //*** Resource_BitmapStrip.cpp *** 00002 00003 #include "Resource_BitmapStrip.h" 00004 #include "ResourceManager.h" 00005 #include "Filename.h" 00006 #include "BitmapStrip.h" 00007 #include "Bitmap_16bit.h" 00008 00009 00010 //*** Constructor *** 00011 00012 Resource_BitmapStrip::Resource_BitmapStrip(): 00013 bitmapStrip_(0) 00014 { 00015 } 00016 00017 //*** Constructor *** 00018 00019 Resource_BitmapStrip::Resource_BitmapStrip(const BitmapStrip* bitmapStrip): 00020 bitmapStrip_(bitmapStrip) 00021 { 00022 } 00023 00024 00025 //*** Constructor *** 00026 00027 Resource_BitmapStrip::Resource_BitmapStrip(const Bitmap* bitmap): 00028 bitmapStrip_(0) 00029 { 00030 bitmapStrip_=siResourceManager->GetBitmapStrip(bitmap); 00031 if (bitmapStrip_) 00032 { 00033 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00034 } 00035 } 00036 00037 00038 //*** Constructor *** 00039 00040 Resource_BitmapStrip::Resource_BitmapStrip(const Filename& filename, int celCount): 00041 bitmapStrip_(0) 00042 { 00043 bitmapStrip_=siResourceManager->GetBitmapStrip(filename.GetStringId(),celCount); 00044 if (bitmapStrip_) 00045 { 00046 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00047 } 00048 } 00049 00050 00051 //*** Constructor *** 00052 00053 Resource_BitmapStrip::Resource_BitmapStrip(const char* filenameStr, int celCount): 00054 bitmapStrip_(0) 00055 { 00056 if (filenameStr) 00057 { 00058 Filename filename(filenameStr); 00059 bitmapStrip_=siResourceManager->GetBitmapStrip(filename.GetStringId(),celCount); 00060 if (bitmapStrip_) 00061 { 00062 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00063 } 00064 } 00065 } 00066 00067 00068 //*** Constructor *** 00069 00070 Resource_BitmapStrip::Resource_BitmapStrip(StringId filenameId, int celCount): 00071 bitmapStrip_(0) 00072 { 00073 Filename filename(filenameId); 00074 bitmapStrip_=siResourceManager->GetBitmapStrip(filename.GetStringId(),celCount); 00075 if (bitmapStrip_) 00076 { 00077 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00078 } 00079 } 00080 00081 00082 //*** Constructor *** 00083 00084 Resource_BitmapStrip::Resource_BitmapStrip(const Image& image): 00085 bitmapStrip_(0) 00086 { 00087 bitmapStrip_=siResourceManager->GetBitmapStrip(image); 00088 if (bitmapStrip_) 00089 { 00090 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00091 } 00092 } 00093 00094 00095 //*** Destructor *** 00096 00097 Resource_BitmapStrip::~Resource_BitmapStrip() 00098 { 00099 if (bitmapStrip_) 00100 { 00101 siResourceManager->DecreaseReferenceCount(bitmapStrip_); 00102 } 00103 } 00104 00105 00107 00108 Resource_BitmapStrip::Resource_BitmapStrip(const Resource_BitmapStrip& resource): 00109 bitmapStrip_(resource.bitmapStrip_) 00110 { 00111 if (bitmapStrip_) 00112 { 00113 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00114 } 00115 } 00116 00117 00118 //*** Assignment operator *** 00119 00120 const Resource_BitmapStrip& Resource_BitmapStrip::operator =(const Resource_BitmapStrip& resource) 00121 { 00122 if (bitmapStrip_) 00123 { 00124 siResourceManager->DecreaseReferenceCount(bitmapStrip_); 00125 } 00126 bitmapStrip_=resource.bitmapStrip_; 00127 if (bitmapStrip_) 00128 { 00129 siResourceManager->IncreaseReferenceCount(bitmapStrip_); 00130 } 00131 return *this; 00132 } 00133 00134 00135 //*** GetBitmapStrip *** 00136 00137 const BitmapStrip& Resource_BitmapStrip::GetBitmapStrip() const 00138 { 00139 if (!bitmapStrip_) 00140 { 00141 static BitmapStrip defaultValue; 00142 return defaultValue; 00143 } 00144 00145 return *bitmapStrip_; 00146 } 00147 00148 00149 //*** GetBitmap *** 00150 00151 const Bitmap& Resource_BitmapStrip::GetBitmap() const 00152 { 00153 if (!bitmapStrip_ || bitmapStrip_->GetCelCount()==0) 00154 { 00155 static Bitmap_16bit defaultValue; 00156 return defaultValue; 00157 } 00158 00159 return bitmapStrip_->GetCel(0); 00160 } 00161 00162 00163 //*** operator const BitmapStrip& *** 00164 00165 Resource_BitmapStrip::operator const BitmapStrip&() const 00166 { 00167 return GetBitmapStrip(); 00168 } 00169 00170 00171 //*** operator const Bitmap& *** 00172 00173 Resource_BitmapStrip::operator const Bitmap&() const 00174 { 00175 return GetBitmap(); 00176 } 00177 00178 int Resource_BitmapStrip::GetCelCount() const 00179 { 00180 return GetBitmapStrip().GetCelCount(); 00181 } 00182 00183 00184 const Bitmap& Resource_BitmapStrip::GetCel(int index) const 00185 { 00186 return GetBitmapStrip().GetCel(index); 00187 } 00188 00189 00190 00191 int Resource_BitmapStrip::GetWidth(int cel) const 00192 { 00193 const BitmapStrip& strip=GetBitmapStrip(); 00194 if (strip.GetCelCount()==0) 00195 { 00196 return 0 ; 00197 } 00198 00199 return strip.GetCel(cel).GetWidth(); 00200 } 00201 00202 int Resource_BitmapStrip::GetHeight(int cel) const 00203 { 00204 const BitmapStrip& strip=GetBitmapStrip(); 00205 if (strip.GetCelCount()==0) 00206 { 00207 return 0; 00208 } 00209 00210 return strip.GetCel(cel).GetHeight(); 00211 } 00212 00213 void Resource_BitmapStrip::Blit(Bitmap& target, int x, int y, unsigned short modulate, unsigned char alpha, Bitmap::Transformation transformation) const 00214 { 00215 GetBitmap().Blit(target,x,y,modulate,alpha,transformation); 00216 } 00217 00218 void Resource_BitmapStrip::Blit(int x1, int y1, int x2, int y2, Bitmap& target, int x,int y, unsigned short modulate, unsigned char alpha, Bitmap::Transformation transformation) const 00219 { 00220 GetBitmap().Blit(x1,y1,x2,y2,target,x,y,modulate,alpha,transformation); 00221 } 00222 00223 void Resource_BitmapStrip::Copy(Bitmap& target, int x, int y, unsigned short modulate, Bitmap::Transformation transformation) const 00224 { 00225 GetBitmap().Copy(target,x,y,modulate,transformation); 00226 } 00227 00228 void Resource_BitmapStrip::Copy(int x1, int y1, int x2, int y2, Bitmap& target, int x, int y, unsigned short modulate, Bitmap::Transformation transformation) const 00229 { 00230 GetBitmap().Copy(x1,y1,x2,y2,target,x,y,modulate,transformation); 00231 } 00232 00233 00234 void Resource_BitmapStrip::Blit(int cel, Bitmap& target, int x, int y, unsigned short modulate, unsigned char alpha, Bitmap::Transformation transformation) const 00235 { 00236 const BitmapStrip& strip=GetBitmapStrip(); 00237 if (strip.GetCelCount()==0) 00238 { 00239 return; 00240 } 00241 strip.GetCel(cel).Blit(target,x,y,modulate,alpha,transformation); 00242 } 00243 00244 void Resource_BitmapStrip::Blit(int cel, int x1, int y1, int x2, int y2, Bitmap& target, int x,int y, unsigned short modulate, unsigned char alpha, Bitmap::Transformation transformation) const 00245 { 00246 const BitmapStrip& strip=GetBitmapStrip(); 00247 if (strip.GetCelCount()==0) 00248 { 00249 return; 00250 } 00251 strip.GetCel(cel).Blit(x1,y1,x2,y2,target,x,y,modulate,alpha,transformation); 00252 } 00253 00254 void Resource_BitmapStrip::Copy(int cel, Bitmap& target, int x, int y, unsigned short modulate, Bitmap::Transformation transformation) const 00255 { 00256 const BitmapStrip& strip=GetBitmapStrip(); 00257 if (strip.GetCelCount()==0) 00258 { 00259 return; 00260 } 00261 strip.GetCel(cel).Copy(target,x,y,modulate,transformation); 00262 } 00263 00264 void Resource_BitmapStrip::Copy(int cel, int x1, int y1, int x2, int y2, Bitmap& target, int x, int y, unsigned short modulate, Bitmap::Transformation transformation) const 00265 { 00266 const BitmapStrip& strip=GetBitmapStrip(); 00267 if (strip.GetCelCount()==0) 00268 { 00269 return; 00270 } 00271 strip.GetCel(cel).Copy(x1,y1,x2,y2,target,x,y,modulate,transformation); 00272 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
