Dnf资本阐明与提取东西(附代码)_langresser的专栏 dnf私服npk

Dnf资本包花样阐明,参考的是这篇文章:http://blog.csdn.net/leexuany/article/details/3849051

提取东西的代码我放到github上了:https://github.com/langresser/dnfextrator

固然上文已有对照详实的阐明了,可是真正完成好一个资本提取东西照旧花了我两天的时候。这里把需求注重的中央记录下来。

1、npk包的花样:

struct NPK_Header { char flag[16]; // 文件标识 “NeoplePack_Bill” int count; // 包内文件的数量 }; struct NPK_Index { unsigned int offset; // 文件的包内偏移量 unsigned int size; // 文件的巨细 char name[256];// 文件名 }; char decord_flag[256] = “puchikon@neople dungeon and fighter DNF”;

FILE *fp = fopen(file_name, “wb”); png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); info_ptr = png_create_info_struct(png_ptr); if (setjmp(png_jmpbuf(png_ptr))) { printf(“[write_png_file] Error during init_io”); return; } png_init_io(png_ptr, fp); /* write header */ if (setjmp(png_jmpbuf(png_ptr))) { printf(“[write_png_file] Error during writing header”); return; } png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_write_info(png_ptr, info_ptr); /* write bytes */ if (setjmp(png_jmpbuf(png_ptr))) { printf(“[write_png_file] Error during writing bytes”); return; } row_pointers = (png_bytep*)malloc(height*sizeof(png_bytep)); for(int i = 0; i < height; i++) { row_pointers[i] = (png_bytep)malloc(sizeof(unsigned char)* 4 * width); for(int j = 0; j < width; ++j) { // png is rgba switch (type) { case ARGB_1555://1555 row_pointers[i][j * 4 + 0] = ((data[i * width * 2 + j * 2 + 1] & 127) >> 2) << 3; // red row_pointers[i][j * 4 + 1] = (((data[i * width * 2 + j * 2 + 1] & 0x0003) << 3) | ((data[i * width * 2 + j * 2] >> 5) & 0x0007)) << 3; // green row_pointers[i][j * 4 + 2] = (data[i * width * 2 + j * 2] & 0x003f) << 3; // blue row_pointers[i][j * 4 + 3] = (data[i * width * 2 + j * 2 + 1] >> 7) == 0 ? 0 : 255; // alpha break; case ARGB_4444://4444 row_pointers[i][j * 4 + 0] = (data[i * width * 2 + j * 2 + 1] & 0x0f) << 4; // red row_pointers[i][j * 4 + 1] = ((data[i * width * 2 + j * 2 + 0] & 0xf0) >> 4) << 4; // green row_pointers[i][j * 4 + 2] = (data[i * width * 2 + j * 2 + 0] & 0x0f) << 4;; // blue row_pointers[i][j * 4 + 3] = ((data[i * width * 2 + j * 2 + 1] & 0xf0) >> 4) << 4; // alpha break; case ARGB_8888://8888 row_pointers[i][j * 4 + 0] = data[i * width * 4 + j * 4 + 2]; // red row_pointers[i][j * 4 + 1] = data[i * width * 4 + j * 4 + 1]; // green row_pointers[i][j * 4 + 2] = data[i * width * 4 + j * 4 + 0]; // blue row_pointers[i][j * 4 + 3] = data[i * width * 4 + j * 4 + 3]; // alpha break; case ARGB_NONE:// 占位,无图片资本 break; default: printf("error known type:%d

点赞

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注