始何写位图的序列化程序!我愿出300分给能正确回答我这个问题的人!!!

edrftgyh 2002-09-22 01:18:44
如何写位图的序列化程序??即serialize(CArchive &ar),如谁能正确回答,我愿另开贴出300分!
...全文
42 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
runnersun 2002-09-24
  • 打赏
  • 举报
回复
将位图元变量定义为基于CObject的类,就重载其虚函数Serialize进行序列化。
guopo 2002-09-23
  • 打赏
  • 举报
回复
check ur email.:)
romanticist 2002-09-23
  • 打赏
  • 举报
回复
扫描行就 是 一 行 一 行 扫 瞄 每 一 个 像 素 点 。 最 简 单 的 说 法 就 是 取 坐 标 点 为X为 0的 点 把 纵 坐 标 的 点 扫 瞄 一 遍 , 然 后 在 接 ,坐 标 点 为X为 1的 点,坐 标 点 为X为 2的 点。 。 。 。 。 。 。 。 。 。 。
edrftgyh 2002-09-23
  • 打赏
  • 举报
回复
请问,一个扫描行指的是什么?
Fishcat 2002-09-22
  • 打赏
  • 举报
回复
msdn里就有一个diblook的示例程序,可以处理bmp的现实与保存,
用的就是序列化。
edrftgyh 2002-09-22
  • 打赏
  • 举报
回复
我知道这种代码有好多,可是用serialize存储的就几乎没有!!
lsgt 2002-09-22
  • 打赏
  • 举报
回复
一般情况下需要把DDB转化成DIB保存,然后按DIB的格式写入文件就可以了。

这样的代码到处都是。
edrftgyh 2002-09-22
  • 打赏
  • 举报
回复
如果会的话,麻烦给一个实例,如真能实现的话,本人一定300分奉上!!
edrftgyh 2002-09-22
  • 打赏
  • 举报
回复
也就是在屏幕上截取任意大小的区域,然后存到硬盘上!!
edrftgyh 2002-09-22
  • 打赏
  • 举报
回复
是这样的,能够将一任意大小张位图用serialize()存储到硬盘中!
我的email是huzhinong@elong.com.
harry202 2002-09-22
  • 打赏
  • 举报
回复
为什么要用序列化啊?只要是个DIB,把内存里面的东西直接存到文件就可以了亚。当然,需要加上BitMap File Header。如果你想方便一点,可以直接用现成的类,如果你需要,我可以发个给你。或者你可以去codeproject.com看看。。里面很多阿。
snake1122 2002-09-22
  • 打赏
  • 举报
回复
瞅瞅:)
edrftgyh 2002-09-22
  • 打赏
  • 举报
回复
能不能详细讲讲这部份是什么意思?
for(j=0;j<bmi.bmiHeader.biWidth;j++)
{
for (k=1; k<4;k++)
{
ar<<bits[cnt];
cnt++;
}
}
for (j=0;j<bmi.bmiHeader.biWidth%4;j++)
{
ar<<bits[cnt];
cnt++; //image has a double word boundary.
}
我知道这样写是为了数据的对齐,可是以的理解,应该不是这样写的啊!
还望高手指点!
oldworm 2002-09-22
  • 打赏
  • 举报
回复
yes , i can
能不能将需求说得更清楚一点?
guopo 2002-09-22
  • 打赏
  • 举报
回复
在VC技术内幕中有现成的类,并且有这个序列话函数,就是文件读写的事。






你要没有我发给你,留EMAIL.
ahphone 2002-09-22
  • 打赏
  • 举报
回复
diblook 里面是标准的文件操作。
下面的代码我可不付责任
void CBitmapDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here

// This code is for 24 Bit Bitmaps only.
int i,j,k; // These are the loop variables
ar<<bmfh.bfType; //bmfh: Bit Map file Header
ar<<bmfh.bfSize ;
ar<<bmfh.bfReserved1;
ar<<bmfh.bfReserved2;
ar<<bmfh.bfOffBits;
ar<<bmi.bmiHeader.biSize; //bmi: Bit Map Info
ar<<bmi.bmiHeader.biWidth;
ar<<bmi.bmiHeader.biHeight;
ar<<bmi.bmiHeader.biPlanes;
ar<<bmi.bmiHeader.biBitCount;
ar<<bmi.bmiHeader.biCompression;
ar<<bmi.bmiHeader.biSizeImage;
ar<<bmi.bmiHeader.biXPelsPerMeter;
ar<<bmi.bmiHeader.biYPelsPerMeter;
ar<<bmi.bmiHeader.biClrUsed;
ar<<bmi.bmiHeader.biClrImportant;
//there is no colour table for 24 bit bitmaps

long int cnt=0; // counter
for(i=0;i<bmi.bmiHeader.biHeight;i++)
{
for(j=0;j<bmi.bmiHeader.biWidth;j++)
{
for (k=1; k<4;k++)
{
ar<<bits[cnt];
cnt++;
}
}
for (j=0;j<bmi.bmiHeader.biWidth%4;j++)
{
ar<<bits[cnt];
cnt++; //image has a double word boundary.
}
}
}
else
{
// TODO: add loading code here
int i,j,k;

ar>>bmfh.bfType; //bmfh:BitMap File Header
ar>>bmfh.bfSize ;
ar>>bmfh.bfReserved1;
ar>>bmfh.bfReserved2;
ar>>bmfh.bfOffBits;
ar>>bmi.bmiHeader.biSize; //bmi: Bit Map Info
ar>>bmi.bmiHeader.biWidth;
ar>>bmi.bmiHeader.biHeight;
ar>>bmi.bmiHeader.biPlanes;
ar>>bmi.bmiHeader.biBitCount;
ar>>bmi.bmiHeader.biCompression;
ar>>bmi.bmiHeader.biSizeImage;
ar>>bmi.bmiHeader.biXPelsPerMeter;
ar>>bmi.bmiHeader.biYPelsPerMeter;
ar>>bmi.bmiHeader.biClrUsed;
ar>>bmi.bmiHeader.biClrImportant;


if (bmi.bmiHeader.biBitCount==24)
{

bits=(unsigned char *) malloc ( ((long int)
( ( bmi.bmiHeader.biWidth*3 +
bmi.bmiHeader.biWidth%4 ) *
bmi.bmiHeader.biHeight )) *
sizeof(unsigned char));

long int cnt=0;

for(i=0;i<bmi.bmiHeader.biHeight;i++)
{
for(j=0;j<bmi.bmiHeader.biWidth;j++)
{
for (k=1; k<4;k++)
{
ar>>bits[cnt];
cnt++;
}
}
for (j=0;j<bmi.bmiHeader.biWidth%4;j++)
{
ar>>bits[cnt];
cnt++;
}
}
}
else
MessageBox(NULL,"Sorry, this is not a 24 Bit Bitmap.",
"File Open Error",MB_ICONSTOP|MB_OK);
}
}
用户 昵称 2002-09-22
  • 打赏
  • 举报
回复
oldworm can

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧