minor format change ; tex demo copy image added
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
#include "utils.h"
|
||||
#include <fstream>
|
||||
#include <assert.h>
|
||||
#include "format.h"
|
||||
|
||||
#define TEX_FORMAT(x) (x==0) ? FORMAT_A8R8G8B8 :(x==1) ? FORMAT_R5G6B5 : (x==2) ? FORMAT_R4G4B4A4 :(x==3) ? FORMAT_A8L8 :(x==4) ? FORMAT_L8 : FORMAT_A8
|
||||
|
||||
#define CBSIZE(x) (x==FORMAT_A8R8G8B8) ? 4 : (x==FORMAT_R5G6B5) ? 2 : (x==FORMAT_R4G4B4A4) ? 2 : (x==FORMAT_A8L8) ? 2 : 1
|
||||
|
||||
|
||||
struct __attribute__((__packed__)) tga_header_t {
|
||||
int8_t idlength;
|
||||
@@ -193,10 +199,58 @@ int CopyBuffers(const SurfaceDesc &dstDesc,
|
||||
if (copyHeight > srcDesc.Height) {
|
||||
copyHeight = srcDesc.Height;
|
||||
}
|
||||
std::cout << "There" << std::endl;
|
||||
|
||||
s_blitTable.get(srcDesc.Format, dstDesc.Format)(
|
||||
dstDesc, dstOffsetX, dstOffsetY, copyWidth, copyHeight, srcDesc,
|
||||
srcOffsetX, srcOffsetY);
|
||||
std::cout << "There2" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConvertImage(std::vector<uint8_t> &dst_pixels,
|
||||
std::vector<uint8_t>&src_pixels,
|
||||
uint32_t *bpp,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint8_t src_format,
|
||||
uint8_t dst_format) {
|
||||
|
||||
uint8_t SrcFormat = TEX_FORMAT(src_format);
|
||||
uint8_t DstFormat = TEX_FORMAT(dst_format);
|
||||
|
||||
*bpp = CBSIZE(DstFormat);
|
||||
|
||||
int32_t src_pitch = CBSIZE(SrcFormat) * width;
|
||||
int32_t dst_pitch = CBSIZE(DstFormat) * width;
|
||||
|
||||
// struct SurfaceDesc {
|
||||
// uint8_t Format;
|
||||
// uint8_t *pBits;
|
||||
// int32_t Width;
|
||||
// int32_t Height;
|
||||
// int32_t Pitch;
|
||||
// };
|
||||
|
||||
const SurfaceDesc srcDesc = {SrcFormat,
|
||||
(uint8_t*)(src_pixels.data()),
|
||||
int32_t(width),
|
||||
int32_t(height),
|
||||
src_pitch} ;
|
||||
|
||||
const SurfaceDesc dstDesc = {DstFormat,
|
||||
(uint8_t*)(dst_pixels.data()),
|
||||
int32_t(width),
|
||||
int32_t(height),
|
||||
dst_pitch};
|
||||
std::cout << "Here" << std::endl;
|
||||
|
||||
|
||||
CopyBuffers(dstDesc, 0, 0, width, height, srcDesc, 0, 0);
|
||||
|
||||
std::cout << "Here" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user