libpng使用例子

游戏素材处理:利用Python把多个序列帧合并为一个大序列图 目录 问题来源 代码解决 游戏素材的整理是一件挺麻烦的事情,但是只要用好了工具,便可以事半功倍。 问题来源 从网上找了一些游戏特效素材,其中包括很多批序列帧图集 一部分特效素材是所有子帧都拼在一张大图上的, 而另一部分是若干个单独的序列帧图片 这样使用起来极其不方便,需要把资源的形式统一。最终决定还是把零散的多个序列帧图片拼成一个大图比较方便管理。 代码解... 阅读详情

本例使用libpng,将一系列单个的序列帧png文件合并成一个大的png, 去除无用的空白,计算每个系列的最小有效范围。

请看源码吧,libpng用法有不明白的,可以参考一下,有抄到的到方请保留版权

 

 

//@author aerror 
//2011/12/02
#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <tchar.h>
#include <vector>
#include <string>
#include <list>


extern "C"{
#include "png.h"
}


	
#define EnsureVectorSize(v,ds)  {if(v.size()<(unsigned int)ds){ v.resize(ds);}}

typedef struct _RECTANGLE
{
	int top;
	int left;
	int bottom;
	int right;
}TRECTANGLE;



class PNG_SRC_FILE
{
public:
	std::string filename;
	png_bytep   bmp;
	unsigned int rawWidth  ;
	unsigned int rawHeight  ;
	PNG_SRC_FILE(const char * src)
	{
		filename =src;
		bmp = NULL;
	}
	virtual ~PNG_SRC_FILE()
	{
		if(bmp!=NULL)
		{
			delete []bmp;
		}
	}

};

typedef std::list<  PNG_SRC_FILE *> TPNG_SRC_FILE_LIST;
typedef std::list<   PNG_SRC_FILE *>::iterator TPNG_SRC_FILE_LIST_ITER;

bool filename_sort(PNG_SRC_FILE * x1,PNG_SRC_FILE * x2)
{
	return x1->filename < x2->filename;
}

typedef struct _tanimation_info
{

	const char *actionName;
	const char *actionDir;
	unsigned rowHeight;
	unsigned frameWidth;
	unsigned frameHeight;
	unsigned totalFrame;
	unsigned fps;
	TPNG_SRC_FILE_LIST  * filelist;
	unsigned int minTop     ;
	unsigned int maxBottom  ;
	unsigned int minLeft    ;
	unsigned int maxRight   ;

}TANIMATION_INFO;

	std::vector<BYTE>				s_srcDibBitsBuffer;
	std::vector<BYTE>				s_dstDibBitsBuffer;
	std::vector<BYTE>				s_dstPngRowsBuffer;
	std::vector<BYTE>				s_dstPngTempBuffer;
	
	

	int outputToPngFileNormal(const char *szFileName,unsigned int numDibBtis,const unsigned char *pDibBytes,unsigned int _width, unsigned int _height)
	{
		FILE *fp;
		png_structp png_ptr;
		png_infop info_ptr;
	

		/* open the file */
		fp = fopen(szFileName, "wb");
		if (fp == NULL)
		  return (ERROR);

		png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL, NULL, NULL);

		if (png_ptr == NULL)
		{
		  fclose(fp);
		  return (ERROR);
		}

		/* Allocate/initialize the image information data.  REQUIRED */
		info_ptr = png_create_info_struct(png_ptr);
		if (info_ptr == NULL)
		{
		  fclose(fp);
		  png_destroy_write_struct(&png_ptr,  png_infopp_NULL);
		  return (ERROR);
		}

		/* Set error handling.  REQUIRED if you aren't supplying your own
		* error handling functions in the png_create_write_struct() call.
		*/
		if (setjmp(png_jmpbuf(png_ptr)))
		{
		  /* If we get here, we had a problem reading the file */
		  fclose(fp);
		  png_destroy_write_struct(&png_ptr, &info_ptr);
		  return (ERROR);
		}

		png_init_io(png_ptr, fp);


		/* Set the image information here.  Width and height are up to 2^31,
		* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
		* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
		* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
		* or PNG_COLOR_TYPE_RGB_ALPHA.  interlace is either PNG_INTERLACE_NONE or
		* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
		* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
		*/
		

		
		int src_bytes_per_pixel	= numDibBtis/_width/_height;	
		png_uint_32 k, height, width;

		height = _height;	
		width = _width;


		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_text text_ptr[2]={0,0};

		char szDetail[255]="pvr";
		/*sprintf(szDetail,"type=%d method=%d size=%dx%d lefttop=%d,%d frame=%dx%d\n",
						pInfo->type,
						pInfo->method,
						(int)(pInfo->width),
						(int)(pInfo->height), 
						(int)(pInfo->left),
						(int)(pInfo->top),
						(int)(pInfo->frmWidth),
						(int)(pInfo->frmHeith) );
*/
		text_ptr[0].key = "Author";
		text_ptr[0].text = "dany21cn@21cn.com";
		text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
		text_ptr[1].key = "Description";
		text_ptr[1].text = szDetail;
		text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
		png_set_text(png_ptr, info_ptr, text_ptr, 2);


		/* Write the file header information.  REQUIRED */
		png_write_info(png_ptr, info_ptr);

		if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
		 png_error (png_ptr, "Image is too tall to process in memory");


		png_bytep image =  NULL;
		png_bytep imagerow =  NULL;
		
		
		EnsureVectorSize(s_dstPngRowsBuffer,width*4);
		imagerow =	&s_dstPngRowsBuffer[0];
		
		
		

		for(int y=0;y<_height;y++)
		{
			for(int x=0;x<_width;x++)
			{
				int dx = x;//+pInfo->left;
				int dy = y;//+pInfo->top;

				if(dx>width || dy>height)
				{
					printf("invalid offset operation\n");
					return ERROR;
				}

				const unsigned char* psrc = pDibBytes + y*_width*src_bytes_per_pixel+ x*src_bytes_per_pixel;
				png_bytep pdst = NULL;
				
				pdst = imagerow  +dx*4;
				
				if(src_bytes_per_pixel==4)
				{
					/*
					pdst[0] = psrc[2];
					pdst[1] = psrc[1];
					pdst[2] = psrc[0];
					pdst[3] = psrc[3];
					*/

					pdst[0] = psrc[0];
					pdst[1] = psrc[1];
					pdst[2] = psrc[2];
					pdst[3] = psrc[3];
				}
			
			}
			
			png_write_row(png_ptr,imagerow);

		}
		
		
		/* You can write optional chunks like tEXt, zTXt, and tIME at the end
		* as well.  Shouldn't be necessary in 1.1.0 and up as all the public
		* chunks are supported and you can use png_set_unknown_chunks() to
		* register unknown chunks into the info structure to be written out.
		*/

		/* It is REQUIRED to call this to finish writing the rest of the file */
		png_write_end(png_ptr, info_ptr);

		/* clean up after the write, and free any memory allocated */
		png_destroy_write_struct(&png_ptr, &info_ptr);

		fclose(fp);

		return 0;
	}


TRECTANGLE cutTransparent(png_bytep bmp, unsigned int width, unsigned int height )
{
	TRECTANGLE  t={0,0,height,width};

	//row by row from top
	//
	for(int y=0;y<height;y++)
	{
		bool thisLineEmpty = true;
		for(int x=0;x<width;x++)
		{
			unsigned char* psrc = bmp + y*width*4+ x*4;
			unsigned  int v =  *(unsigned int* )psrc;
			if(v &0xFF000000)
			{
				thisLineEmpty = false;
				break;
			}
		}

		if(thisLineEmpty)
		{
			t.top ++ ;
		}
		else
		{
			break;
		}
	}

	for(int y=height-1;y>=0;y--)
	{
		bool thisLineEmpty = true;
		for(int x=0;x<width;x++)
		{
			unsigned char* psrc = bmp + y*width*4+ x*4;
			unsigned  int v =  *(unsigned int* )psrc;
			if(v &0xFF000000)
			{
				thisLineEmpty = false;
				break;
			}
		}

		if(thisLineEmpty)
		{
			t.bottom --;
		}
		else
		{
			break;
		}
	}

	
	for(int x=0;x<width;x++)
	{
		bool thisLineEmpty = true;
		for(int y=0;y<height;y++)
		{
			unsigned char* psrc = bmp + y*width*4+ x*4;
			unsigned  int v =  *(unsigned int* )psrc;
			if(v &0xFF000000)
			{
				thisLineEmpty = false;
				break;
			}
		}

		if(thisLineEmpty)
		{
			t.left ++ ;
		}
		else
		{
			break;
		}
	}


	for(int x=width-1;x>=0;x--)
	{
		bool thisLineEmpty = true;
		for(int y=0;y<height;y++)
		{
			unsigned char* psrc = bmp + y*width*4+ x*4;
			unsigned  int v =  *(unsigned int* )psrc;
			if(v &0xFF000000)
			{
				thisLineEmpty = false;
				break;
			}
		}

		if(thisLineEmpty)
		{
			t.right --;
		}
		else
		{
			break;
		}
	}


	return t;
}


/**
stand=standby
attack=Normal attack
squat=Morale attack
attacked=under attack
defense=????
*/


void concat(const char *packsDir, const char *outputDir)
{
	WIN32_FIND_DATAA FindFileData;
	HANDLE hFind = INVALID_HANDLE_VALUE;
	char DirSpec[MAX_PATH];  // directory specification
	char DirBase[MAX_PATH];  // directory specification
	char filename_dest[MAX_PATH];
	char npc_name[MAX_PATH];

	DWORD dwError;


	TANIMATION_INFO aniInfo[4]={
		{ "stand","standby",0,0,0,0,0,0,0,0,0,0},
		{ "attack","Normal attack",0,0,0,0,0,0,0,0,0,0},
		{ "squat","Morale attack",0,0,0,0,0,0,0,0,0,0},
		{ "attacked","under attack",0,0,0,0,0,0,0,0,0,0}
	};

	
	strcpy(DirSpec,packsDir);
	int rlen = strlen(DirSpec);
	if(DirSpec[rlen -1]=='\\')
	{
		DirSpec[rlen-1]='\0';
	}
	strcpy(DirBase,DirSpec);
	char *last = strrchr(DirBase,'\\');
	strcpy(npc_name,last+1);


	char szCurPath[MAX_PATH];


	GetCurrentDirectoryA(MAX_PATH,szCurPath);
	
	unsigned int currentRowHeight = 0;
	unsigned int output_width=0;
	unsigned int output_height=0;
	for(int n=0;n<4;n++)
	{
	
		strcpy(DirSpec,DirBase);
		strcat(DirSpec,"\\序列\\");
		strcat(DirSpec,aniInfo[n].actionDir);
		SetCurrentDirectoryA(DirSpec);
		strcat(DirSpec,"\\*.png");
		
		aniInfo[n].filelist = new TPNG_SRC_FILE_LIST();
		TPNG_SRC_FILE_LIST &filelist = *aniInfo[n].filelist;

		hFind = FindFirstFileA(DirSpec, &FindFileData);
		if (hFind != INVALID_HANDLE_VALUE) 
		{
			while (FindNextFileA(hFind, &FindFileData) != 0) 
			{
				filelist.push_back(new PNG_SRC_FILE(FindFileData.cFileName));
			}
			dwError = GetLastError();
			FindClose(hFind);
		}

		if(filelist.empty())
		{
			continue;
		}

		filelist.sort(filename_sort);


		//剪切
		//
		unsigned int minTop    =0 ;
		unsigned int maxBottom =0 ;
		unsigned int minLeft   =0 ;
		unsigned int maxRight  =0 ;

		for(TPNG_SRC_FILE_LIST_ITER  iter = filelist.begin(); 
			iter !=filelist.end(); iter++)
		{
		
			png_structp png_ptr=NULL;
			png_infop info_ptr=NULL;
			png_infop end_info_ptr=NULL;

			/* open the file */
			FILE *fp = fopen((*iter)->filename.c_str(), "rb");
			if (fp == NULL)
				return ;
			png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL, NULL, NULL);
			info_ptr = png_create_info_struct(png_ptr);
			end_info_ptr = png_create_info_struct(png_ptr);
			png_init_io(png_ptr, fp);
			png_read_info(png_ptr,info_ptr);

			png_bytep dibbytes = new png_byte[info_ptr->width * info_ptr->height * 4];
			
			(*iter)->bmp = dibbytes ;
			(*iter)->rawWidth = info_ptr->width;
			(*iter)->rawHeight = info_ptr->height;
			
			
			for(int y=0;y<info_ptr->height;y++)
			{
				png_bytep pdest = dibbytes + y*info_ptr->width*4;
				png_read_row(png_ptr,pdest,NULL);
			}

			TRECTANGLE cut = cutTransparent(dibbytes,info_ptr->width,info_ptr->height);
			if(minTop==0 || minTop> cut.top)
			{
				minTop = cut.top;
			}
			if(minLeft==0 || minLeft> cut.left)
			{
				minLeft = cut.left;
			}

			if(maxRight < cut.right)
			{
				maxRight = cut.right;
			}
			
			if(maxBottom < cut.bottom)
			{
				maxBottom  = cut.bottom;
			}
			

			png_destroy_read_struct(&png_ptr,&info_ptr,&end_info_ptr);
			fclose(fp);
		}

		
		aniInfo[n].fps = 10;
		aniInfo[n].frameWidth = maxRight - minLeft;
		aniInfo[n].frameHeight  = maxBottom-minTop;
		aniInfo[n].totalFrame= filelist.size();
		aniInfo[n].rowHeight = currentRowHeight;
		aniInfo[n].minTop     =minTop     ;
		aniInfo[n].maxBottom  =maxBottom  ;
		aniInfo[n].minLeft    =minLeft    ;
		aniInfo[n].maxRight   =maxRight   ;

		currentRowHeight += aniInfo[n].frameHeight;

		if(output_width  < aniInfo[n].frameWidth * aniInfo[n].totalFrame)
		{
			output_width   = aniInfo[n].frameWidth * aniInfo[n].totalFrame;
		}

		output_height = currentRowHeight;
	}
	
	EnsureVectorSize(s_srcDibBitsBuffer, output_height * output_width * 4);

	png_bytep  bigmap = &s_srcDibBitsBuffer[0];
	currentRowHeight = 0;
	
	std::string xml;
	const char *headline_fmt =  "<SWFLoader isBattle=\"true\" name=\"%s\" url=\"assets/soldiers/%s.swf\" load=\"false\">\n";
	const char *actionline_fmt =  "  <action name=\"%s\" rowHeight=\"%d\" frameWidth=\"%d\" frameHeight=\"%d\" fps=\"120\" totalFrame=\"%d\" attackFrame=\"0\" attackedFrame=\"0\" isRight=\"true\" offsetX=\"115\" offsetY=\"-268\"/>\n";
	const char *endline_fmt =  "</SWFLoader>\n";
	sprintf(DirSpec,headline_fmt,npc_name,npc_name);
	xml = DirSpec;

	for(int n=0;n<4;n++)
	{
		
		TPNG_SRC_FILE_LIST &filelist = *aniInfo[n].filelist;
		if(filelist.empty())
		{
			continue;
		}

		sprintf(DirSpec,actionline_fmt,aniInfo[n].actionName,aniInfo[n].rowHeight,aniInfo[n].frameWidth,aniInfo[n].frameHeight,aniInfo[n].totalFrame);
		xml +=DirSpec;

		int curCol= 0;
		for(TPNG_SRC_FILE_LIST_ITER   iter = filelist.begin(); 
			iter !=filelist.end(); iter++)
		{
			int yy = 0;
			for(int y=aniInfo[n].minTop;y<aniInfo[n].maxBottom;y++)
			{
				int xx = 0;
				for(int x=aniInfo[n].minLeft;x<aniInfo[n].maxRight;x++)
				{
					unsigned int* psrc = (unsigned int*)((*iter)->bmp + y*(*iter)->rawWidth *4+ x*4);
					int dx =  curCol * aniInfo[n].frameWidth  +  xx;
					int dy =  currentRowHeight +yy;
					unsigned int* dest = (unsigned int*)(bigmap + dy * output_width * 4 + dx*4);
					xx++;
					*dest = *psrc;
				}

				yy ++;
			}
			
			curCol ++;
			PNG_SRC_FILE * f = *iter;
			delete f;
		}

		delete aniInfo[n].filelist;

		currentRowHeight += aniInfo[n].frameHeight;
	}
	xml += endline_fmt;


	SetCurrentDirectoryA(szCurPath);

	strcpy(filename_dest,outputDir);
	if(outputDir[strlen(outputDir)-1]!='\\')
		strcat(filename_dest,"\\");
	strcat(filename_dest,npc_name);
	strcat(filename_dest,".png");
	outputToPngFileNormal(filename_dest,4*output_width * output_height, &s_srcDibBitsBuffer[0],output_width,output_height);

	strcpy(filename_dest,outputDir);
	
	if(outputDir[strlen(outputDir)-1]!='\\')
		strcat(filename_dest,"\\");
	strcat(filename_dest,"AnimationConfig.xml");

	FILE *xmlFile = fopen(filename_dest,"a");
	
	if(xmlFile==NULL)
	{
		return ;
	}

	fwrite(xml.c_str(),1,xml.length(),xmlFile);
	fclose(xmlFile);
}

void print_uasge()
{
	printf("USEAGE:\n"
			"   pngconcat  x:\\path\\to\\yournpcdirectory x:\\path\\to\\output \n"
			"EXAMPLE:\n"
			"   pngconcat  D:\\hero_xxxxxx D:\\temp \n"
			);
}

int checkDir(const char * szdir)
{
	 struct _stat buf;
   int result;
   char timebuf[26];
   const char* filename = szdir;
   errno_t err;

   // Get data associated with "crt_stat.c": 
   result = _stat( filename, &buf );

   // Check if statistics are valid: 
   if( result != 0 )
   {
      perror( "Problem getting information" );
      switch (errno)
      {
         case ENOENT:
           printf("File %s not found.\n", filename);
           break;
         case EINVAL:
           printf("Invalid parameter to _stat.\n");
           break;
         default:
           /* Should never be reached. */
           printf("Unexpected error in _stat.\n");
      }
	  return -1;
   }
   else
   {
	   if( (buf.st_mode & _S_IFDIR)==0)
	   {
		     printf("input %s is not a directory.\n", filename);
			 return -1;
	   }
		
   }
   return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
	
	if(argc != 3 || checkDir(argv[1])  || checkDir(argv[2]) )
	{
		print_uasge();
		return -1;
	}

	concat(argv[1],argv[2]);
	return 0;
}


 

使用libpng和GDI读取显示png图片 网上都是gdiplus的例子,其实GDI也是支持透明度的,放一个例子。 #include "png.h" #include "zlib.h" #include #pragma comment(lib, "Msimg32.lib")//AlphaBlend需要 void Draw(HWND hwnd, const char* pngfile, bool layered) { 阅读详情

相关推荐

使用libpng读写PNG图片

libpng是一款C语言编写的比较底层的读写PNG文件的跨平台的库。借助它,你可以轻松读写PNG文件的每一行像素。 因为PNG文件是经过压缩而且格式复杂的图形文件(有的PNG文件甚至像GIF文件一样带动画效果) 而且PNG可以是带透明通道的真彩色图像、不带透明通道的真彩色图像、索引颜色、灰度颜色等各种格式,如果大家都自己写程序分析PNG文件就会显得很麻烦、很累。因此,通过使用libpng你就能直接...

wang93IT的博客 1万+

libpng样例

读取png文件: #include #include #include /******************************图片数据*********************************/ typedef struct _pic_data pic_data; struct _pic_data { int width, height; /* 尺寸 */ int b

xiaolu 记录 1063

使用libpng读取PNG图片像素数据

libpng 是一套免费的、公开源代码的程序库,支持对 PNG 图形文件的创建、读写等操作。可以到www.libpng.org 上下载源代码。libpng 使用 zlib 程序库作为压缩引擎,zlib 也是著名的 gzip (GNU zip) 所采用的压缩引擎。zlib是通用的压缩库,提供了一套 in-memory 压缩和解压函数,并能检测解压出来的数据的完整性(integrity)。

2万+

【Photoshop】合并一系列序列帧图片成序列帧大图

在2D游戏中,序列帧图片的大图是很常见很常用的东西,他用于记录游戏主角的所有动作。比如上图,就是lf2中的一张序列帧大图。 其实大部分软件都不支持gif或者直接拉个视频进去这样,序列帧图片来完成游戏主角的动作表现这项技术一直很经典。所以我们需要学会利用Photoshop合并一系列序列帧图片成序列帧大图。 一般用视频软件或者Gif处理软件导出来的帧系列图片是这样的: 你不可能拿这多达1

编程记录,亲测有效 5万+

libpng的使用 | 在Linux系统下编译、安装与使用

libpng是官方的 PNG 参考库。它支持几乎所有 PNG 功能,具有可扩展性,并且经过了 23 多年的广泛测试。开发版本的主页(即可能有问题 或可能会发生变化或包含实验性功能)是https://libpng.sourceforge.io/,有关该库的问题的地方是png-mng-implement邮件列表。 libpng 可作为 ANSI C (C89) 源代码使用,并且需要zlib 1.0.4 或更高版本(出于性能和安全原因,建议使用1.2.5或更高版本)。

I_feige的博客 7457

深入解析libpng-1.2.23:PNG图像处理库核心功能

本文还有配套的精品资源,点击获取 简介:PNG是一种无损压缩图像格式,广泛用于网页设计和软件开发。libpng-1.2.23是该格式处理库的一个稳定版本,提供了全面的PNG标准支持,包含透明度、颜色空间转换等核心功能。该文详细介绍libpng的核心特性、使用方法及其在实际项目中的应用。libpng库由解码器、编码器、内存管理、错误处理和API接口等组件构成。使用该库涉及解压...

weixin_42584507的博客 2009

linux下libpng库的安装以及使用

前几天手里的智能锁项目 , 收到产品的建议(命令)说 , 就是人脸识别成功的时候 , 不要只显示摄像头捕捉到的图像 , 要弄个酷炫一点的背景, 背景里图片中间有个圆圈, 人脸就放到圆圈里也就是类似这样。。 当然, 这是我思考了好几个小时的结果, 开始想不明白要怎么实现,其实想通了也很简单, 三个步骤 A 把背景图像的RGB读出来 out_buf B 把摄像头采集到的图像读出来(分辨率和背...

weixin_38176039的博客 3万+

序列帧合并器 max序列帧.zip

一款不错的序列帧合成器,很好用可以自行设置行数、列数,还能设置多行,自动裁剪png图片,一键设置图片合成,有需要的欢迎下载。

libpng使用

最近看到一片关于如何使用C语言读和写png图片格式 我要讲的三个大部分分别是: 1、libpng是什么,能做什么? 2、怎样让自己的程序可以使用libpng库? 3、怎样借助libpng读写PNG文件 1、libpng是什么? libpng是一款C语言编写的比较底层的读写PNG文件的跨平台的库。借助它,你可以轻松读写PNG文件的每一行像素。 因为PNG文件是经过压缩而且格式复

化茧成蝶007 1万+

从爱好者到工程师:如何低成本体验RFSoC ZU47DR?性能实测与避坑指南

本文详细介绍了如何低成本体验赛灵思RFSoC ZU47DR芯片,包括二手开发板选购、租赁服务、精简开发环境搭建等实用方案。通过性能实测与避坑指南,帮助爱好者和工程师在有限预算下充分利用这款集成了ARM处理器和FPGA的高性能芯片,降低开发门槛。

weixin_42525005的博客 226

STM32C8T6实战:用PID算法搞定超级电容的10W无线恒功率充电(附代码避坑)

本文详细介绍了如何使用STM32C8T6和PID算法实现超级电容的10W无线恒功率充电。通过优化硬件设计、动态调整PID参数以及三重滤波技术,解决了超级电容充电过程中的功率尖峰和效率问题。附有代码示例和调试经验,帮助开发者快速实现高效稳定的无线充电方案。

weixin_29190169的博客 413

Libpng源码的使用

上一篇讲了libpng和zlib的关系 zlib,Libpng,gzip,libzip库的联系与区别 接下来记录libpng的使用 准备 首先了解png,bmp文件格式的特点,本篇不详细介绍。 bmp图片是微软的图片格式,就是原始的像素数据加上bmp文件头组成,像素数据是倒装的,即第一个像素的(RGB)三个字节再原始文件的最后。png是原始数据压缩后加入png格式文件描述。 下载libpng和zlib的源码,放在同一个目录中 由于libpng实际上使用的是zlib的算法,libpng是zl

cc电子世界 5615

飞牛NAS挂载115网盘避坑指南:为什么你的大文件总是传输失败?

本文深入解析了在飞牛NAS上通过AList挂载115网盘时,大文件传输失败的深层原因,包括风控机制、网络协议及兼容性问题。文章提供了从基础排查到高阶优化的系统性解决方案,并建议采用Kopia分片备份等终极策略,以实现稳定可靠的云端数据流转。

weixin_29306011的博客 1733

libpng库的使用讲解

由于个人想学习DirectFB的使用。而 DirectFB依赖于libpng和libjpeg库,所以需要简单了解下libpng库的使用方法。本文转自:http://www.cnblogs.com/xiaoxiaoboke/archive/2012/02/13/2349765.html。此篇文章讲解的非常不错。我个人会有简单的调整。新增了一个小例子对使用来个简单的小结。   libpng的数据结

ostar_liang的专栏 1万+

大模型事件抽取学习——论文学习笔记《LLMs Learn Task Heuristics from Demonstrations:......》

本篇博客介绍一篇发表在2024 ACL main上的文章:《LLMs Learn Task Heuristics from Demonstrations: A Heuristic-Driven Prompting Strategy for Document-Level Event Argument Extraction》 方向:大模型事件抽取 本篇博客为个人阅读论文的总结与笔记,在这里进行简单的分享 论文链接:https://arxiv.org/abs/

weixin_53751318的博客 1862

从入门到精通:dirmap 高级 Web 目录扫描实战指南

本文提供了一份从环境搭建到高级配置的dirmap Web目录扫描实战指南。详细解析了工具安装、核心配置文件dirmap.conf的深度调优,包括递归扫描、四种扫描模式(字典、爆破、爬虫、Fuzz)的实战应用,并演示了分阶段资产发现的完整工作流程,帮助安全人员高效发现隐藏目录与敏感文件。

rnn9storyteller的博客 483

libpng的简单使用

libpng的简单使用

Karl的专栏 5887

移动支付APP(仿支付宝)

Toast.makeText(PayActivity.this, "支付失败:" + payResponse.getMsg(), Toast.LENGTH_SHORT).show();Toast.makeText(PayActivity.this, "支付失败:" + t.getMessage(), Toast.LENGTH_SHORT).show();Toast.makeText(PayActivity.this, "支付失败", Toast.LENGTH_SHORT).show();

寒寒豆豆软件公司的博客 143

[libpng]CMake+VS2015下编译libpng,及使用小例

编译前的工作 在编译libpng前,需要把zlib编译好,并加载到编译环境里。 CMake + VS2015 下编译zlib,及使用小例 下载与解压 libpng的官网是 http://www.libpng.org/pub/png/libpng.html ,但它的源码是存在 https://sourceforge.net 上的;具体最新的版本可以先进官网看看,再点连接过去下载 我当...

weixin_30425949的博客 595

prplOS amx-fxgi调试-订阅subscribe

本文分析了prplOS中amx-fxgi订阅功能(subscribe)的实现与调试过程。通过梳理订阅流程发现,默认订阅失败主要由于acl规则限制导致。文章详细介绍了订阅的两个关键步骤:建立GET长连接和POST设置订阅路径,并通过修改代码绕过acl验证成功实现订阅功能。最终验证了在同一连接下订阅多个路径及实时接收状态更新的可行性,有效降低了设备查询负载。该方案为prplOS的实时数据监控提供了优化思路。

四儿家的小祖宗的博客 338

【AI Agent 记忆共享实战】【下篇】多 Agent 会话 Session 统一共享实战:全链路工程落地、采集归一、MCP 服务、私有化部署、源码级实战

中篇我们已经锁定最终最优架构方案: 非侵入式、外部旁路采集、只读归一、中心化存储、MCP 按需检索注入。摒弃「改 Agent 源码」「软链接互通」「原生 Session 互导」等不现实方案。本篇直接落地可上线、可简历复用、可个人私有化部署多 Agent 异构 Session专属采集器(Claude/CODex/DSH/OpenCode/Kimi/WorkBuddy/ 豆包)统一消息归一化解析层(解决所有 Schema 异构)增量同步、去重、时间戳对齐核心逻辑。

十年老程序猿,AI 疯狂研究专家,前沿硬核知识分享 500

libpng 项目使用与配置教程

libpng 项目是一个用于处理 Portable Network Graphics (PNG) 文件格式的库。项目的目录结构如下: - `.github/`: 存放 GitHub Actions 的配置文件,用于自动化构建和测试等。 - `contrib/`: 包含了一些额外的、非官方的代码贡献。 - `scripts/`: 存放了一些辅助脚本,用于构建和测试等。 - `tests/`: 包含...

gitblog_01016的博客 753

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

zlib 与 libpng 的配置与使用 part 3 libpng的安装与生成PNG图片

libpng 的安装接下来,安装 libpng 的过程要稍微轻松些。先下载最新的 libpng 程序库源文件。网址是http://sourceforge.net/projects/libpng/或http://www.libpng.org/pub/png/。不妨设下载的文件是 libpng-1.2.5.tar.gz,将这个文件释放到D:/libpng/。修改D:/libpng/libpng

陈硕的Blog 2万+

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: 排序组合,AS实现穷举算法
下一篇: LZMA 算法 AS3 移植 实现
aerror
博客等级 码龄23年 393粉丝 193原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值