پاسخ : هر سوال برنامه نویسی دارید بپرسید(C++,C#,java)
ino tu borland c++ neveshtam baiad az alloc.h tu borlant va allocators.h tu vc++ estefade konid
class hbitmap
{
public:
long int FileType[1];
long int FileSize[1];
long int Reserved1[1];
long int Reserved2[1];
long int BitmapOffset[1];
long int Size[1];
long int Width[1];
long int Height[1];
long int Planes[1];
long int BitsPerPixel[1];
long int Compression[1];
long int SizeOfBitmap[1];
long int HorzResolution[1];
long int VertResolution[1];
long int ColorsUsed[1];
long int ColorsImportant[1];
long int RedMask[1];
long int GreenMask[1];
long int BlueMask[1];
long int AlphaMask[1];
long int CSType[1];
long int RedX[1];
long int RedY[1];
long int RedZ[1];
long int GreenX[1];
long int GreenY[1];
long int GreenZ[1];
long int BlueX[1];
long int BlueY[1];
long int BlueZ[1];
long int GammaRed[1];
long int GammaGreen[1];
long int GammaBlue[1];
bitmaprgb *rgb;
string bitmap;
FILE* BITMAP;
void getimage(char path[100])
{
bitmap=path;
BITMAP=fopen(bitmap.string1,"rb");
fread (FileType,2,1,BITMAP);
fread (FileSize,4,1,BITMAP);
fread (Reserved1,2,1,BITMAP);
fread (Reserved2,2,1,BITMAP);
fread (BitmapOffset,4,1,BITMAP);
fread (Size,4,1,BITMAP);
fread (Width,4,1,BITMAP);
fread (Height,4,1,BITMAP);
fread (Planes,2,1,BITMAP);
fread (BitsPerPixel,2,1,BITMAP);
fread (Compression,4,1,BITMAP);
fread (SizeOfBitmap,4,1,BITMAP);
fread (HorzResolution,4,1,BITMAP);
fread (VertResolution,4,1,BITMAP);
fread (ColorsUsed,4,1,BITMAP);
fread (ColorsImportant,4,1,BITMAP);
if (Size[0]==108)
{
fread (RedMask,4,1,BITMAP);
fread (GreenMask,4,1,BITMAP);
fread (BlueMask,4,1,BITMAP);
fread (AlphaMask,4,1,BITMAP);
fread (CSType,4,1,BITMAP);
fread (RedX,8,1,BITMAP);
fread (RedY,8,1,BITMAP);
fread (RedZ,8,1,BITMAP);
fread (GreenX,8,1,BITMAP);
fread (GreenY,8,1,BITMAP);
fread (GreenZ,8,1,BITMAP);
fread (BlueX,8,1,BITMAP);
fread (BlueY,8,1,BITMAP);
fread (BlueZ,8,1,BITMAP);
fread (GammaRed,4,1,BITMAP);
fread (GammaGreen,4,1,BITMAP);
fread (GammaBlue,4,1,BITMAP);
}
if (BitsPerPixel[0]>15)
ColorsUsed[0] = 1 << BitsPerPixel[0];
rgb=(bitmaprgb*)malloc(Height[0]*Width[0]*3);
fread (rgb,3,Height[0]*Width[0],BITMAP);
fclose(BITMAP);
}
void savebmp(char path[100])
{
bitmap=path;
BITMAP=fopen(bitmap.string1,"wb");
fwrite (FileType,2,1,BITMAP);
fwrite (FileSize,4,1,BITMAP);
fwrite (Reserved1,2,1,BITMAP);
fwrite (Reserved2,2,1,BITMAP);
fwrite (BitmapOffset,4,1,BITMAP);
fwrite (Size,4,1,BITMAP);
fwrite (Width,4,1,BITMAP);
fwrite (Height,4,1,BITMAP);
fwrite (Planes,2,1,BITMAP);
fwrite (BitsPerPixel,2,1,BITMAP);
fwrite (Compression,4,1,BITMAP);
fwrite (SizeOfBitmap,4,1,BITMAP);
fwrite (HorzResolution,4,1,BITMAP);
fwrite (VertResolution,4,1,BITMAP);
fwrite (ColorsUsed,4,1,BITMAP);
fwrite (ColorsImportant,4,1,BITMAP);
if (Size[0]==108)
{
fwrite (RedMask,4,1,BITMAP);
fwrite (GreenMask,4,1,BITMAP);
fwrite (BlueMask,4,1,BITMAP);
fwrite (AlphaMask,4,1,BITMAP);
fwrite (CSType,4,1,BITMAP);
fwrite (RedX,8,1,BITMAP);
fwrite (RedY,8,1,BITMAP);
fwrite (RedZ,8,1,BITMAP);
fwrite (GreenX,8,1,BITMAP);
fwrite (GreenY,8,1,BITMAP);
fwrite (GreenZ,8,1,BITMAP);
fwrite (BlueX,8,1,BITMAP);
fwrite (BlueY,8,1,BITMAP);
fwrite (BlueZ,8,1,BITMAP);
fwrite (GammaRed,4,1,BITMAP);
fwrite (GammaGreen,4,1,BITMAP);
fwrite (GammaBlue,4,1,BITMAP);
}
if (BitsPerPixel[0]>15)
ColorsUsed[0] = 1 << BitsPerPixel[0];
fwrite (rgb,3,Height[0]*Width[0],BITMAP);
fclose(BITMAP);
}
};
in class file bitmap baz mikone baad rang haro tu rgb zaxire mikone badd mishe harkari mixay bahash bokoni rang ha tu rgb besurat satr satr zaxire shode yani pixel ha ba tatib (0,0) (1,0) (2,0) (3,1) . . . . (w-1,0) (0,1) . . . . (1,1) .... (w-1,1) . . . . . (w-1,l-1) ba in tartib umadan albatte baiad file bit map 24bit bashe