Переглянути джерело

Fix docs and naming convention for Pixel class

Daniele Bartolini 12 роки тому
батько
коміт
e345f6618b
4 змінених файлів з 17 додано та 17 видалено
  1. 5 5
      src/Image.cpp
  2. 5 3
      src/Pixel.cpp
  3. 6 8
      src/Pixel.h
  4. 1 1
      src/TextureResource.cpp

+ 5 - 5
src/Image.cpp

@@ -115,14 +115,14 @@ PixelFormat Image::GetFormat() const
 	return mPixelFormat;
 	return mPixelFormat;
 }
 }
 
 
-uint32_t Image::GetBitsPerPixel() const
+uint32_t Image::GetBytesPerPixel() const
 {
 {
-	return Pixel::GetBitsPerPixel(mPixelFormat);
+	return Pixel::bytes_per_pixel(mPixelFormat);
 }
 }
 
 
-uint32_t Image::GetBytesPerPixel() const
+uint32_t Image::GetBitsPerPixel() const
 {
 {
-	return Pixel::GetBytesPerPixel(mPixelFormat);
+	return Pixel::bytes_per_pixel(mPixelFormat);
 }
 }
 
 
 uint8_t* Image::GetBuffer()
 uint8_t* Image::GetBuffer()
@@ -215,7 +215,7 @@ void Image::SetPixel(uint32_t x, uint32_t y, Color4 color)
 		throw ArgumentException("Coordinates outside the Image");
 		throw ArgumentException("Coordinates outside the Image");
 	}*/
 	}*/
 
 
-	int32_t bpp = 3;//GetBytesPerPixel();
+	int32_t bpp = 3;//bytes_per_pixel();
 	int32_t offset = (y * mWidth + x) * GetBytesPerPixel();
 	int32_t offset = (y * mWidth + x) * GetBytesPerPixel();
 	mBuffer[offset    ] = (uint8_t)(color.r * 255);
 	mBuffer[offset    ] = (uint8_t)(color.r * 255);
 	mBuffer[offset + 1] = (uint8_t)(color.g * 255);
 	mBuffer[offset + 1] = (uint8_t)(color.g * 255);

+ 5 - 3
src/Pixel.cpp

@@ -29,7 +29,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-uint32_t Pixel::GetBitsPerPixel(PixelFormat format)
+//-----------------------------------------------------------------------------
+uint32_t Pixel::bits_per_pixel(PixelFormat format)
 {
 {
 	switch (format)
 	switch (format)
 	{
 	{
@@ -108,9 +109,10 @@ uint32_t Pixel::GetBitsPerPixel(PixelFormat format)
 	}
 	}
 }
 }
 
 
-uint32_t Pixel::GetBytesPerPixel(PixelFormat format)
+//-----------------------------------------------------------------------------
+uint32_t Pixel::bytes_per_pixel(PixelFormat format)
 {
 {
-	return GetBitsPerPixel(format) / 8;
+	return bits_per_pixel(format) / 8;
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 6 - 8
src/Pixel.h

@@ -40,9 +40,8 @@ namespace crown
 // [36 - 39]	-> 128-bit
 // [36 - 39]	-> 128-bit
 // 40			-> Unknown (0-bit)
 // 40			-> Unknown (0-bit)
 
 
-/**
-	Enumerates pixel formats.
-*/
+
+/// Enumerates pixel formats.
 enum PixelFormat
 enum PixelFormat
 {
 {
 	PF_L_8 = 0,				//!< Luminance only, 8-bit
 	PF_L_8 = 0,				//!< Luminance only, 8-bit
@@ -101,14 +100,13 @@ enum PixelFormat
 
 
 class Pixel
 class Pixel
 {
 {
-
 public:
 public:
 
 
-	//! Returns the format's bytes per pixel
-	static uint32_t GetBytesPerPixel(PixelFormat format);
+	/// Returns the bytes per pixel necessary to @format pixel format
+	static uint32_t bytes_per_pixel(PixelFormat format);
 
 
-	//! Returns the format's bits per pixel
-	static uint32_t GetBitsPerPixel(PixelFormat format);
+	/// Returns the bits per pixel necessary to @format pixel format
+	static uint32_t bits_per_pixel(PixelFormat format);
 
 
 private:
 private:
 
 

+ 1 - 1
src/TextureResource.cpp

@@ -23,7 +23,7 @@ void* TextureResource::load(Allocator& allocator, ResourceArchive& archive, Reso
 		stream->read(&resource->m_width, sizeof(uint16_t));
 		stream->read(&resource->m_width, sizeof(uint16_t));
 		stream->read(&resource->m_height, sizeof(uint16_t));
 		stream->read(&resource->m_height, sizeof(uint16_t));
 	
 	
-		size_t size = resource->m_width * resource->m_height * Pixel::GetBytesPerPixel(resource->m_format);
+		size_t size = resource->m_width * resource->m_height * Pixel::bytes_per_pixel(resource->m_format);
 
 
 		resource->m_data = (uint8_t*)allocator.allocate(sizeof(uint8_t) * size);
 		resource->m_data = (uint8_t*)allocator.allocate(sizeof(uint8_t) * size);