image: add area and is_packed methods
This commit is contained in:
parent
3a39b282a5
commit
7e00b7d096
@ -96,6 +96,7 @@ UTIL_FILES = \
|
||||
hash/wang.ipp \
|
||||
image.cpp \
|
||||
image.hpp \
|
||||
image.ipp \
|
||||
introspection.cpp \
|
||||
introspection.hpp \
|
||||
io.cpp \
|
||||
|
@ -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
38
image.ipp
Normal 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;
|
||||
}
|
||||
} }
|
Loading…
Reference in New Issue
Block a user