image: add area and is_packed methods

This commit is contained in:
Danny Robson 2015-06-04 14:34:13 +10:00
parent 3a39b282a5
commit 7e00b7d096
3 changed files with 44 additions and 0 deletions

View File

@ -96,6 +96,7 @@ UTIL_FILES = \
hash/wang.ipp \
image.cpp \
image.hpp \
image.ipp \
introspection.cpp \
introspection.hpp \
io.cpp \

View File

@ -48,6 +48,9 @@ namespace util { namespace image {
buffer<T> downsample (float factor) const;
constexpr size_t area (void) const;
constexpr bool is_packed (void) const;
size_t w;
size_t h;
size_t s;
@ -71,4 +74,6 @@ namespace util { namespace image {
};
} }
#include "image.ipp"
#endif

38
image.ipp Normal file
View File

@ -0,0 +1,38 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2011-2015 Danny Robson <danny@nerdcruft.net>
*/
#ifdef __UTIL_IMAGE_IPP
#error
#endif
#define __UTIL_IMAGE_IPP
namespace util { namespace image {
//-------------------------------------------------------------------------
template <typename T>
constexpr size_t
buffer<T>::area (void) const
{
return w * h;
}
//-------------------------------------------------------------------------
template <typename T>
constexpr bool
buffer<T>::is_packed (void) const
{
return s == w;
}
} }