大家有没有编写或保存ico的程序源码呢?小弟找了很久,好象delphi没有这方面的例子。在线等待。
解决方案 »
- TreeView生成树形结构,数据库结构比较特别,本人是通过递归画树的方式,画TreeView树,但是不成功,请各位高手不吝赐教;
- 菜鸟提问!!
- 紧急请求(在线等待):关于用wise打包的问题,打包后出现数据库连接失败!BDE + Paradox
- 问一个歌曲的名字
- 关于提取图标的问题???ExtractIcon问题???????????????????
- 密码验证的问题,帮忙看一下啊,。。。谢谢了
- 请大家帮忙,到那里有win api函数的文本下载啊?
- 用IE的ActiveX,如何监视和过滤当前页面下载的内容,如图片视频等内容?
- 如何往Exe文件中加入字符串
- delphi 中除了“TWebBrowser”有没有其它的可以浏览网页的组件?
- TDBGrid的行选定
- 如何取得本机的计算机名和IP地址 再线等
MicroAngelo
http://www.51icon.net/web/software_view.asp?SuperCode=icon&LargeCode=software&id=2
Borland\delphi7\demos\resxplor
what's in an icon?
an icon resource can contain multiple icon images. for example, one icon resource--in this case, a single .ico file--can contain images in several sizes and color depths:
the ico file
an icon file, which usually has the ico extension, contains one icon resource. given that an icon resource can contain multiple images, it is no surprise that the file begins with an icon directory:
typedef struct
{
word idreserved; // reserved (must be 0)
word idtype; // resource type (1 for icons)
word idcount; // how many images?
icondirentry identries[1]; // an entry for each image (idcount of 'em)
} icondir, *lpicondir;
the idcount member indicates how many images are present in the icon resource. the size of the identries array is determined by idcount. there exists one icondirentry for each icon image in the file, providing details about its location in the file, size and color depth. the icondirentry structure is defined as:
typedef struct
{
byte bwidth; // width, in pixels, of the image
byte bheight; // height, in pixels, of the image
byte bcolorcount; // number of colors in image (0 if >=8bpp)
byte breserved; // reserved ( must be 0)
word wplanes; // color planes
word wbitcount; // bits per pixel
dword dwbytesinres; // how many bytes in this resource?
dword dwimageoffset; // where in the file is this image?
} icondirentry, *lpicondirentry;
for each icondirentry, the file contains an icon image. the dwbytesinres member indicates the size of the image data. this image data can be found dwimageoffset bytes from the beginning of the file, and is stored in the following format:
typdef struct
{
bitmapinfoheader icheader; // dib header
rgbquad iccolors[1]; // color table
byte icxor[1]; // dib bits for xor mask
byte icand[1]; // dib bits for and mask
} iconimage, *lpiconimage;the icheader member has the form of a dib bitmapinfoheader. only the following members are used: bisize, biwidth, biheight, biplanes, bibitcount, bisizeimage. all other members must be 0. the biheight member specifies the combined height of the xor and and masks. the members of icheader define the contents and sizes of the other elements of the iconimage structure in the same way that the bitmapinfoheader structure defines a cf_dib format dib.
the iccolors member is an array of rgbquads. the number of elements in this array is determined by examining the icheader member.
the icxor member contains the dib bits for the xor mask of the image. the number of bytes in this array is determined by examining the icheader member. the xor mask is the color portion of the image and is applied to the destination using the xor operation after the application of the and mask.
the icand member contains the bits for the monochrome and mask. the number of bytes in this array is determined by examining the icheader member, and assuming 1bpp. the dimensions of this bitmap must be the same as the dimensions of the xor mask. the and mask is applied to the destination using the and operation, to preserve or remove destination pixels before applying the xor mask.
note the biheight member of the icheader structure represents the combined height of the xor and and masks. remember to divide this number by two before
procedure Bmp2Ico(bmp, ico: string);
var
IconSizeX : integer;
IconSizeY : integer;
myBmp : TBitmap;
AndMask : TBitmap;
XOrMask : TBitmap;
IconInfo : TIconInfo;
Icon : TIcon;
begin
IconSizeX := GetSystemMetrics(SM_CXICON);
IconSizeY := GetSystemMetrics(SM_CYICON); myBmp := TBitmap.Create;
myBmp.LoadFromFile(bmp); AndMask := TBitmap.Create;
AndMask.Width := IconSizeX;
AndMask.Height := IconSizeY;
AndMask.Canvas.Brush.Color := clBlack;
AndMask.Canvas.Rectangle(0, 0, IconSizeX, IconSizeY); XOrMask := TBitmap.Create;
XOrMask.Width := IconSizeX;
XOrMask.Height := IconSizeY;
StretchBlt(XorMask.Canvas.Handle, 0, 0, IconSizeX, IconSizeY,
myBmp.Canvas.Handle, 0, 0, myBmp.Width, myBmp.Height, SRCCOPY); Icon := TIcon.Create;
IconInfo.fIcon := true;
IconInfo.xHotspot := 0;
IconInfo.yHotspot := 0;
IconInfo.hbmMask := AndMask.Handle;
IconInfo.hbmColor := XOrMask.Handle;
Icon.Handle := CreateIconIndirect(IconInfo); AndMask.Free;
XOrMask.Free;
myBmp.Free; Icon.SaveToFile(ico);
Icon.Free;
end;
applications. The file consists of an icon directory identifying the number
and types of icon images in the file, plus one or more icon images. The
default filename extension for an icon-resource file is .ICO.Icon DirectoryEach icon-resource file starts with an icon directory. The icon directory,
defined as an ICONDIR structure, specifies the number of icons in the
resource and the dimensions and color format of each icon image. The ICONDIR
structure has the following form:typedef struct ICONDIR {
WORD idReserved;
WORD idType;
WORD idCount;
ICONDIRENTRY idEntries[1];
} ICONHEADER;Following are the members in the ICONDIR structure:idReserved Reserved; must be zero.
idType Specifies the resource type. This member is set to 1.
idCount Specifies the number of entries in the directory.
idEntries Specifies an array of ICONDIRENTRY structures containing
information about individual icons. The idCount member specifies the number
of structures in the array.The ICONDIRENTRY structure specifies the dimensions and color format for an
icon. The structure has the following form:struct IconDirectoryEntry {
BYTE bWidth;
BYTE bHeight;
BYTE bColorCount;
BYTE bReserved;
WORD wPlanes;
WORD wBitCount;
DWORD dwBytesInRes;
DWORD dwImageOffset;
};Following are the members in the ICONDIRENTRY structure: bWidth Specifies the width of the icon, in pixels. Acceptable values
are 16, 32, and 64.bHeight Specifies the height of the icon, in pixels. Acceptable
values are 16, 32, and 64.bColorCount Specifies the number of colors in the icon. Acceptable values
are 2, 8, and 16.bReserved Reserved; must be zero.
wPlanes Specifies the number of color planes in the icon bitmap.
wBitCount Specifies the number of bits in the icon bitmap.
dwBytesInRes Specifies the size of the resource, in bytes.
dwImageOffset Specifies the offset, in bytes, from the beginning of the
file to the icon image.Icon ImageEach icon-resource file contains one icon image for each image identified in
the icon directory. An icon image consists of an icon-image header, a color
table, an XOR mask, and an AND mask. The icon image has the following form:BITMAPINFOHEADER icHeader;
RGBQUAD icColors[];
BYTE icXOR[];
BYTE icAND[];The icon-image header, defined as a BITMAPINFOHEADER structure, specifies the
dimensions and color format of the icon bitmap. Only the biSize through
biBitCount members and the biSizeImage member are used. All other members
(such as biCompression and biClrImportant) must be set to zero.The color table, defined as an array of RGBQUAD structures, specifies the
colors used in the XOR mask. As with the color table in a bitmap file, the
biBitCount member in the icon-image header determines the number of elements
in the array. For more information about the color table, see Section 1.1,
"Bitmap-File Formats."The XOR mask, immediately following the color table, is an array of BYTE
values representing consecutive rows of a bitmap. The bitmap defines the
basic shape and color of the icon image. As with the bitmap bits in a bitmap
file, the bitmap data in an icon-resource file is organized in scan lines,
with each byte representing one or more pixels, as defined by the color
format. For more information about these bitmap bits, see Section 1.1,
"Bitmap-File Formats."The AND mask, immediately following the XOR mask, is an array of BYTE values,
representing a monochrome bitmap with the same width and height as the XOR
mask. The array is organized in scan lines, with each byte representing 8
pixels.When Windows draws an icon, it uses the AND and XOR masks to combine the icon
image with the pixels already on the display surface. Windows first applies
the AND mask by using a bitwise AND operation; this preserves or removes
existing pixel color. Windows then applies the XOR mask by using a bitwise
XOR operation. This sets the final color for each pixel.The following illustration shows the XOR and AND masks that create a
monochrome icon (measuring 8 pixels by 8 pixels) in the form of an uppercase
K:Windows Icon SelectionWindows detects the resolution of the current display and matches it against
the width and height specified for each version of the icon image. If Windows
determines that there is an exact match between an icon image and the current
device, it uses the matching image. Otherwise, it selects the closest match
and stretches the image to the proper size.If an icon-resource file contains more than one image for a particular
resolution, Windows uses the icon image that most closely matches the color
capabilities of the current display. If no image matches the device
capabilities exactly, Windows selects the image that has the greatest number
of colors without exceeding the number of display colors. If all images
exceed the color capabilities of the current display, Windows uses the icon
image with the least number of colors.