add more struct and enum. impl some functions
This commit is contained in:
48
LibCmo/VxMath/VxEnums.hpp
Normal file
48
LibCmo/VxMath/VxEnums.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "../VTUtils.hpp"
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
|
||||
namespace LibCmo::VxMath {
|
||||
|
||||
/**
|
||||
@brief Pixel format types.
|
||||
@see VxImageDesc2PixelFormat, VxPixelFormat2ImageDesc
|
||||
*/
|
||||
enum class VX_PIXELFORMAT : uint32_t {
|
||||
UNKNOWN_PF = 0, /**< Unknown pixel format */
|
||||
_32_ARGB8888 = 1, /**< 32-bit ARGB pixel format with alpha */
|
||||
_32_RGB888 = 2, /**< 32-bit RGB pixel format without alpha */
|
||||
_24_RGB888 = 3, /**< 24-bit RGB pixel format */
|
||||
_16_RGB565 = 4, /**< 16-bit RGB pixel format */
|
||||
_16_RGB555 = 5, /**< 16-bit RGB pixel format (5 bits per color) */
|
||||
_16_ARGB1555 = 6, /**< 16-bit ARGB pixel format (5 bits per color + 1 bit for alpha) */
|
||||
_16_ARGB4444 = 7, /**< 16-bit ARGB pixel format (4 bits per color) */
|
||||
_8_RGB332 = 8, /**< 8-bit RGB pixel format */
|
||||
_8_ARGB2222 = 9, /**< 8-bit ARGB pixel format */
|
||||
_32_ABGR8888 = 10, /**< 32-bit ABGR pixel format */
|
||||
_32_RGBA8888 = 11, /**< 32-bit RGBA pixel format */
|
||||
_32_BGRA8888 = 12, /**< 32-bit BGRA pixel format */
|
||||
_32_BGR888 = 13, /**< 32-bit BGR pixel format */
|
||||
_24_BGR888 = 14, /**< 24-bit BGR pixel format */
|
||||
_16_BGR565 = 15, /**< 16-bit BGR pixel format */
|
||||
_16_BGR555 = 16, /**< 16-bit BGR pixel format (5 bits per color) */
|
||||
_16_ABGR1555 = 17, /**< 16-bit ABGR pixel format (5 bits per color + 1 bit for alpha) */
|
||||
_16_ABGR4444 = 18, /**< 16-bit ABGR pixel format (4 bits per color) */
|
||||
_DXT1 = 19, /**< S3/DirectX Texture Compression 1 */
|
||||
_DXT2 = 20, /**< S3/DirectX Texture Compression 2 */
|
||||
_DXT3 = 21, /**< S3/DirectX Texture Compression 3 */
|
||||
_DXT4 = 22, /**< S3/DirectX Texture Compression 4 */
|
||||
_DXT5 = 23, /**< S3/DirectX Texture Compression 5 */
|
||||
_16_V8U8 = 24, /**< 16-bit Bump Map format format (8 bits per color) */
|
||||
_32_V16U16 = 25, /**< 32-bit Bump Map format format (16 bits per color) */
|
||||
_16_L6V5U5 = 26, /**< 16-bit Bump Map format format with luminance */
|
||||
_32_X8L8V8U8 = 27, /**< 32-bit Bump Map format format with luminance */
|
||||
_8_ABGR8888_CLUT = 28, /**< 8 bits indexed CLUT (ABGR) */
|
||||
_8_ARGB8888_CLUT = 29, /**< 8 bits indexed CLUT (ARGB) */
|
||||
_4_ABGR8888_CLUT = 30, /**< 4 bits indexed CLUT (ABGR) */
|
||||
_4_ARGB8888_CLUT = 31, /**< 4 bits indexed CLUT (ARGB) */
|
||||
};
|
||||
|
||||
}
|
49
LibCmo/VxMath/VxMath.hpp
Normal file
49
LibCmo/VxMath/VxMath.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "../VTUtils.hpp"
|
||||
#include "../CK2/CKTypes.hpp"
|
||||
#include "VxTypes.hpp"
|
||||
|
||||
namespace LibCmo::VxMath {
|
||||
|
||||
// ========== Structure copying ==========
|
||||
|
||||
/**
|
||||
* @brief Fills a memory buffer with a source buffer pattern.
|
||||
* @param Count[in] Number of element to set in the destination buffer
|
||||
* @param Dst[out] Destination buffer
|
||||
* @param Stride[in] Amount in bytes between each element in the destination buffer
|
||||
* @param SizeSrc[in] Size in bytes (but must be a multiple of 4) of an element int the Src buffer
|
||||
* @param Src[in] Source buffer
|
||||
* @remark This function can be used to initialized an array of structure when only some members should be modified.
|
||||
*/
|
||||
void VxFillStructure(CK2::CKDWORD Count, void* Dst, CK2::CKDWORD Stride, CK2::CKDWORD SizeSrc, const void* Src);
|
||||
/**
|
||||
* @brief copies an array of elements between two memory buffers.
|
||||
* @param Count[in] Number of element to copy in the destination buffer
|
||||
* @param Dst[out] Destination buffer
|
||||
* @param OutStride[in] Amount in bytes between each element in the destination buffer
|
||||
* @param SizeSrc[in] Size in bytes (but must be a multiple of 4) of an element
|
||||
* @param Src[in] Source buffer.
|
||||
* @param InStride[in] Amount in bytes between each element in the source buffer
|
||||
* @remark This function can be used to initialized an array of structure when only some members should be modified.
|
||||
*/
|
||||
void VxCopyStructure(CK2::CKDWORD Count, void* Dst, CK2::CKDWORD OutStride, CK2::CKDWORD SizeSrc, const void* Src,CK2::CKDWORD InStride);
|
||||
|
||||
// ========== Graphic Utilities ==========
|
||||
|
||||
/**
|
||||
* @brief Sets the alpha component of an image.
|
||||
* @param dst_desc[in] A pointer to a structure describing the destination image format.
|
||||
* @param AlphaValue[in] A CKBYTE value containing the alpha value to set to the whole image
|
||||
* @remark If the destination image does not have alpha information the function returns immediatly.
|
||||
*/
|
||||
void VxDoAlphaBlit(const VxImageDescEx* dst_desc, CK2::CKBYTE AlphaValue);
|
||||
/**
|
||||
* @brief Sets the alpha component of an image.
|
||||
* @param dst_desc[in] A pointer to a structure describing the destination image format.
|
||||
* @param AlphaValues[in] A BYTE array containing the alpha values for each pixel. This array should be allocated to Width*Height bytes.
|
||||
* @remark If the destination image does not have alpha information the function returns immediatly.
|
||||
*/
|
||||
void VxDoAlphaBlit(const VxImageDescEx* dst_desc, CK2::CKBYTE* AlphaValues);
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "../VTUtils.hpp"
|
||||
#include "../CK2/CKTypes.hpp"
|
||||
#include "VxEnums.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <cinttypes>
|
||||
#include "../CK2/CKTypes.hpp"
|
||||
|
||||
/**
|
||||
* @brief The VxMath part of LibCmo.
|
||||
@ -73,36 +75,52 @@ namespace LibCmo::VxMath {
|
||||
* Colormap, Image pointer and is ready for future enhancements.
|
||||
*/
|
||||
struct VxImageDescEx {
|
||||
CK2::CKINT Size; ///< Size of the structure
|
||||
CK2::CKDWORD Flags; ///< Reserved for special formats (such as compressed ) 0 otherwise
|
||||
VX_PIXELFORMAT Flags; /**< Reserved for special formats (such as compressed ) 0 otherwise */
|
||||
|
||||
CK2::CKINT Width; ///< Width in pixel of the image
|
||||
CK2::CKINT Height; ///< Height in pixel of the image
|
||||
CK2::CKDWORD Width; /**< Width in pixel of the image */
|
||||
CK2::CKDWORD Height; /**< Height in pixel of the image */
|
||||
union {
|
||||
CK2::CKINT BytesPerLine; ///< Pitch (width in bytes) of the image
|
||||
CK2::CKINT TotalImageSize; ///< For compressed image (DXT1...) the total size of the image
|
||||
CK2::CKDWORD BytesPerLine; /**< Pitch (width in bytes) of the image */
|
||||
CK2::CKDWORD TotalImageSize; /**< For compressed image (DXT1...) the total size of the image */
|
||||
};
|
||||
CK2::CKINT BitsPerPixel; ///< Number of bits per pixel
|
||||
CK2::CKINT BitsPerPixel; /**< Number of bits per pixel */
|
||||
union {
|
||||
CK2::CKDWORD RedMask; ///< Mask for Red component
|
||||
CK2::CKDWORD BumpDuMask; ///< Mask for Bump Du component
|
||||
CK2::CKDWORD RedMask; /**< Mask for Red component */
|
||||
CK2::CKDWORD BumpDuMask; /**< Mask for Bump Du component */
|
||||
};
|
||||
union {
|
||||
CK2::CKDWORD GreenMask; ///< Mask for Green component
|
||||
CK2::CKDWORD BumpDvMask; ///< Mask for Bump Dv component
|
||||
CK2::CKDWORD GreenMask; /**< Mask for Green component */
|
||||
CK2::CKDWORD BumpDvMask; /**< Mask for Bump Dv component */
|
||||
};
|
||||
union {
|
||||
CK2::CKDWORD BlueMask; ///< Mask for Blue component
|
||||
CK2::CKDWORD BumpLumMask; ///< Mask for Luminance component
|
||||
CK2::CKDWORD BlueMask; /**< Mask for Blue component */
|
||||
CK2::CKDWORD BumpLumMask; /**< Mask for Luminance component */
|
||||
|
||||
};
|
||||
CK2::CKDWORD AlphaMask; ///< Mask for Alpha component
|
||||
CK2::CKDWORD AlphaMask; /**< Mask for Alpha component */
|
||||
|
||||
CK2::CKWORD BytesPerColorEntry; ///< ColorMap Stride
|
||||
CK2::CKWORD ColorMapEntries; ///< If other than 0 image is palletized
|
||||
CK2::CKWORD BytesPerColorEntry; /**< ColorMap Stride */
|
||||
CK2::CKWORD ColorMapEntries; /**< If other than 0 image is palletized */
|
||||
|
||||
CK2::CKBYTE* ColorMap; /**< Palette colors */
|
||||
CK2::CKBYTE* Image; /**< Image */
|
||||
|
||||
bool HasAlpha() {
|
||||
return (AlphaMask == 0 || Flags >= VX_PIXELFORMAT::_DXT1);
|
||||
}
|
||||
|
||||
bool operator==(const VxImageDescEx& rhs) const {
|
||||
return (
|
||||
Height == rhs.Height && Width == rhs.Width &&
|
||||
BitsPerPixel == rhs.BitsPerPixel && BytesPerLine == rhs.BytesPerLine &&
|
||||
RedMask == rhs.RedMask && GreenMask == rhs.GreenMask && BlueMask == rhs.BlueMask && AlphaMask == rhs.AlphaMask &&
|
||||
BytesPerColorEntry == rhs.BytesPerColorEntry && ColorMapEntries == rhs.ColorMapEntries
|
||||
);
|
||||
}
|
||||
bool operator!=(const VxImageDescEx& rhs) const {
|
||||
return !((*this) == rhs);
|
||||
}
|
||||
|
||||
CK2::CKBYTE* ColorMap; ///< Palette colors
|
||||
CK2::CKBYTE* Image; ///< Image
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user