关于图象切割的问题!求助! 假如有一图片,长100宽100 现要根据需要把这张图片均匀的分割成若干小块并分别保存,比如要分成10*10块,要达到这个目的如何实现呢?不论用什么方法都可以,能用DELPHI实现更好!有谁知道望告知!先谢过了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FT,我居然帮人写过一段需求完全一样的代码...不过...因为只是帮忙,比较偷懒,代码丑了点,效率也差了,凑和着看吧BOOL Bmp_Incise(const char *filename){ BITMAPFILEHEADER bmpfileheader; BITMAPINFOHEADER bmpinfoheader; ifstream bmpfile; bmpfile.open(filename, ios::in|ios::binary); if(!bmpfile) { return false; } else { bmpfile.read((char *)&bmpfileheader, sizeof(bmpfileheader)); if(bmpfileheader.bfType != 0x4D42) return false; bmpfile.read((char *)&bmpinfoheader, sizeof(bmpinfoheader)); if(bmpinfoheader.biWidth == 0 || bmpinfoheader.biHeight == 0) return false; if(bmpinfoheader.biWidth != 100 || bmpinfoheader.biHeight != 100) return false; if(bmpinfoheader.biPlanes != 1) return false; if(bmpinfoheader.biBitCount != 24 && bmpinfoheader.biBitCount != 32) return false; if(bmpinfoheader.biCompression != 0) return false; if(bmpinfoheader.biSizeImage % 4 != 0) return false; } ofstream outfile[10]; int bit = bmpinfoheader.biBitCount / 8; char *buf = new char[100 * bit]; for(int i=0; i<10; i++) { char str[20]; for(int j=0; j<10; j++) { sprintf(str, "%d", i * 10 + j + 1); strcat(str, ".bmp\0"); outfile[j].open((char *)str, ios::out|ios::binary); bmpinfoheader.biWidth = 10; bmpinfoheader.biHeight = 10; bmpinfoheader.biSizeImage = ((10 * bit - 1) / 4 + 1) * 4 * 10; bmpfileheader.bfSize = bmpinfoheader.biSizeImage + sizeof(bmpfileheader) + sizeof(bmpinfoheader); outfile[j].write((char *)&bmpfileheader, sizeof(bmpfileheader)); outfile[j].write((char *)&bmpinfoheader, sizeof(bmpinfoheader)); } for(int j=0; j<10; j++) { for(int k=0; k<10; k++) { bmpfile.read(buf, 10 * bit); outfile[k].write(buf, 10 * bit); if(bit = 3) { outfile[k].put(0); outfile[k].put(0); } } } for(int j=0; j<10; j++) { outfile[j].close(); } } delete[] buf; return true;} 用Rxlib组件里面的picclip就完全OK了 或者直接copyrect也行,很简单的啊:P 为什么调用文件流的free方法后,文件依然被占用呢 宽带拨号设置代理的问题 Delphi中年周转换为日期算法 谁有kvlabel控件,,,急 如何动态设置quickreport的横打竖打? 特急,文本写到ACCESS库(在线等) 关于stringgrid的简单问题! 一个关于报表制作的QQ群:6030791 挺简单的sql语句,快来领分!!! 请教MediaPlayer的使用 用SocketConnection来连接三层的服务器的时候,在启动的时候为什么会出现一个空白的Form,怎么让它不显示? 使用自己的UNIT的方法??
{
BITMAPFILEHEADER bmpfileheader;
BITMAPINFOHEADER bmpinfoheader;
ifstream bmpfile;
bmpfile.open(filename, ios::in|ios::binary);
if(!bmpfile) {
return false;
}
else {
bmpfile.read((char *)&bmpfileheader, sizeof(bmpfileheader));
if(bmpfileheader.bfType != 0x4D42) return false;
bmpfile.read((char *)&bmpinfoheader, sizeof(bmpinfoheader));
if(bmpinfoheader.biWidth == 0 || bmpinfoheader.biHeight == 0) return false;
if(bmpinfoheader.biWidth != 100 || bmpinfoheader.biHeight != 100) return false;
if(bmpinfoheader.biPlanes != 1) return false;
if(bmpinfoheader.biBitCount != 24 && bmpinfoheader.biBitCount != 32) return false;
if(bmpinfoheader.biCompression != 0) return false;
if(bmpinfoheader.biSizeImage % 4 != 0) return false;
}
ofstream outfile[10];
int bit = bmpinfoheader.biBitCount / 8;
char *buf = new char[100 * bit];
for(int i=0; i<10; i++) {
char str[20];
for(int j=0; j<10; j++) {
sprintf(str, "%d", i * 10 + j + 1);
strcat(str, ".bmp\0");
outfile[j].open((char *)str, ios::out|ios::binary);
bmpinfoheader.biWidth = 10;
bmpinfoheader.biHeight = 10;
bmpinfoheader.biSizeImage = ((10 * bit - 1) / 4 + 1) * 4 * 10;
bmpfileheader.bfSize = bmpinfoheader.biSizeImage + sizeof(bmpfileheader) + sizeof(bmpinfoheader);
outfile[j].write((char *)&bmpfileheader, sizeof(bmpfileheader));
outfile[j].write((char *)&bmpinfoheader, sizeof(bmpinfoheader));
}
for(int j=0; j<10; j++) {
for(int k=0; k<10; k++) {
bmpfile.read(buf, 10 * bit);
outfile[k].write(buf, 10 * bit);
if(bit = 3) {
outfile[k].put(0);
outfile[k].put(0);
}
}
}
for(int j=0; j<10; j++) {
outfile[j].close();
}
}
delete[] buf;
return true;
}