SOIL 创建图片

#include <iostream>
#include <string>
using namespace std;
#include "../../src/socket/TCPSocketEx.h"
#include <cocos2d.h>
using namespace cocos2d;
#include "../../src/socket/Private/MemoryPool.h"
#include "../../src/socket/ServerService.h"
#include "external/xxtea/xxtea.h"
#include "cocos/base/ccUtils.h"
extern "C"
{
#include "md5/md5.h"
}
#include "SOIL2.h"


int main()
{
    const int w = 100;
    const int h = 100;
    const int size = w * h * 4;
    unsigned char data[size] = { 0 };
    
    for (int i = 0; i < size; i += 4)
    {
        data[i] = 255;//r
        data[i + 1] = 0;//g
        data[i + 2] = 0;//b
        data[i + 3] = 255;//a
    }

    auto ret = SOIL_save_image("D:/PriPro/NDKLIB/t.png", SOIL_SAVE_TYPE_PNG, w, h, SOIL_LOAD_RGBA, data);
    printf("ret %d\n", ret);


    unsigned char buf[40000] = { 0 };
    int W, H, C;
    auto d = SOIL_load_image("D:/PriPro/NDKLIB/test.png", &W, &H, &C, 0);
    memcpy(buf, d,40000);





    int var = 0;
    return 0;
}

posted @ 2020-09-27 19:36  YZFHKMS-X  阅读(218)  评论(0编辑  收藏  举报