X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fimage.cc;fp=src%2FMoof%2FImage.cc;h=f2f0c09294654145b89e068ebc34a0384c8d8ccf;hp=158135287b7f727822e03b3ad5ad2e2144e0c641;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hpb=299af4f2047e767e5d79501c26444473bda64c64 diff --git a/src/Moof/Image.cc b/src/moof/image.cc similarity index 62% rename from src/Moof/Image.cc rename to src/moof/image.cc index 1581352..f2f0c09 100644 --- a/src/Moof/Image.cc +++ b/src/moof/image.cc @@ -17,42 +17,41 @@ #include #include -#include "Backend.hh" -#include "Error.hh" -#include "Image.hh" -#include "Log.hh" -#include "Manager.hh" +#include "backend.hh" +#include "image.hh" +#include "log.hh" +#include "manager.hh" -namespace Mf { +namespace moof { -class Image::Impl : public Manager +class image::impl : public manager { public: - explicit Impl() : - mContext(0), - mPixels(0) {} + explicit impl() : + context_(0), + pixels_(0) {} - ~Impl() + ~impl() { - SDL_FreeSurface(mContext); - delete[] mPixels; + SDL_FreeSurface(context_); + delete[] pixels_; } void flip() { - unsigned char* pixels = (Uint8*)(mContext->pixels); + unsigned char* pixels = (Uint8*)(context_->pixels); - unsigned pitch = mContext->pitch; + unsigned pitch = context_->pitch; unsigned char line[pitch]; int yBegin = 0; - int yEnd = mContext->h - 1; + int yEnd = context_->h - 1; - if (SDL_MUSTLOCK(mContext)) SDL_LockSurface(mContext); + if (SDL_MUSTLOCK(context_)) SDL_LockSurface(context_); while (yBegin < yEnd) { memcpy(line, pixels + pitch * yBegin, pitch); @@ -61,12 +60,12 @@ public: yBegin++; yEnd--; } - if (SDL_MUSTLOCK(mContext)) SDL_UnlockSurface(mContext); + if (SDL_MUSTLOCK(context_)) SDL_UnlockSurface(context_); } - void setAsIcon() const + void set_as_icon() const { - SDL_WM_SetIcon(mContext, 0); + SDL_WM_SetIcon(context_, 0); } @@ -74,7 +73,7 @@ public: { std::string path(name); - FILE* fp = Image::openFile(path); + FILE* fp = image::open_file(path); if (!fp) return; png_byte signature[8]; @@ -94,7 +93,7 @@ public: png_bytepp rows = 0; png_textp texts = 0; - int numTexts; + int nutext_s; bytesRead = fread(signature, 1, sizeof(signature), fp); if (bytesRead < sizeof(signature) || @@ -138,18 +137,18 @@ public: bpp = png_get_bit_depth(pngObj, pngInfo); channels = png_get_channels(pngObj, pngInfo); - mDepth = bpp * channels; + depth_ = bpp * channels; - if (channels == 3) mColorMode = GL_RGB; - else mColorMode = GL_RGBA; + if (channels == 3) color_mode_ = GL_RGB; + else color_mode_ = GL_RGBA; // read comments - png_get_text(pngObj, pngInfo, &texts, &numTexts); - for (int i = 0; i < numTexts; ++i) + png_get_text(pngObj, pngInfo, &texts, &nutext_s); + for (int i = 0; i < nutext_s; ++i) { if (strncmp(texts[i].key, "TextureInfo", 11) == 0) { - mComment = texts[i].text; + comment_ = texts[i].text; break; } } @@ -158,14 +157,14 @@ public: height = png_get_image_height(pngObj, pngInfo); pitch = png_get_rowbytes(pngObj, pngInfo); - mPixels = new char[width * pitch]; + pixels_ = new char[width * pitch]; rows = new png_bytep[height]; if (flipped) { for (int i = 0; i < height; ++i) { - rows[height - 1 - i] = (png_bytep)(mPixels + + rows[height - 1 - i] = (png_bytep)(pixels_ + i * channels * width); } } @@ -173,16 +172,16 @@ public: { for (int i = 0; i < height; ++i) { - rows[i] = (png_bytep)(mPixels + i * channels * width); + rows[i] = (png_bytep)(pixels_ + i * channels * width); } } png_read_image(pngObj, rows); png_read_end(pngObj, 0); - mContext = SDL_CreateRGBSurfaceFrom + context_ = SDL_CreateRGBSurfaceFrom ( - mPixels, + pixels_, width, height, bpp * channels, @@ -210,94 +209,94 @@ public: } - SDL_Surface* mContext; - char* mPixels; + SDL_Surface* context_; + char* pixels_; - unsigned mDepth; - GLuint mColorMode; + unsigned depth_; + GLuint color_mode_; - std::string mComment; + std::string comment_; private: - Backend mBackend; + backend backend_; }; -Image::Image(const std::string& name) : +image::image(const std::string& name) : // pass through - mImpl(Image::Impl::getInstance(name)) {} + impl_(image::impl::instance(name)) {} -bool Image::isValid() const +bool image::is_valid() const { - return mImpl->mContext; + return impl_->context_; } -int Image::getWidth() const +int image::width() const { - return mImpl->mContext->w; + return impl_->context_->w; } -int Image::getHeight() const +int image::height() const { - return mImpl->mContext->h; + return impl_->context_->h; } -unsigned Image::getDepth() const +unsigned image::depth() const { - return mImpl->mDepth; + return impl_->depth_; } -unsigned Image::getPitch() const +unsigned image::pitch() const { - return mImpl->mContext->pitch; + return impl_->context_->pitch; } -GLuint Image::getMode() const +GLuint image::mode() const { - return mImpl->mColorMode; + return impl_->color_mode_; } -std::string Image::getComment() const +std::string image::comment() const { - return mImpl->mComment; + return impl_->comment_; } -const char* Image::getPixels() const +const char* image::pixels() const { - return mImpl->mPixels; + return impl_->pixels_; } -char* Image::getPixels() +char* image::pixels() { - return mImpl->mPixels; + return impl_->pixels_; } -void Image::flip() +void image::flip() { // pass through - mImpl->flip(); + impl_->flip(); } -void Image::setAsIcon() const +void image::set_as_icon() const { // pass through - mImpl->setAsIcon(); + impl_->set_as_icon(); } -bool Image::getPath(std::string& name) +bool image::find_path(std::string& name) { - return Resource::getPath(name, "images/", "png"); + return resource::find_path(name, "images/", "png"); } -FILE* Image::openFile(std::string& name) +FILE* image::open_file(std::string& name) { - return Resource::openFile(name, "images/", "png"); + return resource::open_file(name, "images/", "png"); } -} // namespace Mf +} // namespace moof