Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Мультимедиа в Delphi
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 27.07.2010, 21:12   #21
x128
Форумчанин
 
Регистрация: 03.02.2010
Сообщений: 178
По умолчанию

подправил процедуру:
Код:
procedure SaveIcon(fname: string);
type
  TIconRec = packed record
    Width: byte;
    Height: byte;
    Colors: byte;
    Reserved: byte;
    Planes: word;
    BPP: word;
    DIBSize: dword;
    DIBOffset: dword;
  end;
  TCursorOrIcon = packed record
    Reserved: word;
    wType: word;
    Count: word;
  end;
var
  i: integer;
  ico: file of byte;
  hdr: TCursorOrIcon;
  irec: TIconRec;
  binfo: TBitmapInfoHeader;
  mask: TBitmap;
begin
  hdr.Reserved:=0;
  hdr.wType:=1;
  hdr.Count:=1;
  AssignFile(ico, fname);
  Rewrite(ico);
  BlockWrite(ico, hdr, SizeOf(hdr));

  if bmp.Width<256 then irec.Width:=bmp.Width else irec.Width:=0;
  if bmp.Height<256 then irec.Height:=bmp.Height else irec.Height:=0;
  irec.Colors:=0;
  irec.Reserved:=0;
  irec.Planes:=0;
  irec.BPP:=32;
  irec.DIBSize:=(bmp.Width*bmp.Height*4)+(bmp.Width*bmp.Height div 8);
  irec.DIBOffset:=SizeOf(hdr)+SizeOf(irec);
  BlockWrite(ico, irec, SizeOf(irec));

  binfo.biSize:=SizeOf(binfo);
  binfo.biWidth:=bmp.Width;
  binfo.biHeight:=bmp.Height*2;
  binfo.biPlanes:=1;
  binfo.biBitCount:=32;
  binfo.biCompression:=BI_RGB;
  binfo.biSizeImage:=bmp.Width*bmp.Height*4;
  binfo.biXPelsPerMeter:=0;
  binfo.biYPelsPerMeter:=0;
  binfo.biClrUsed:=0;
  binfo.biClrImportant:=0;
  BlockWrite(ico, binfo, SizeOf(binfo));
  for i:=bmp.Height-1 downto 0 do BlockWrite(ico, bmp.ScanLine[i]^, bmp.Width*4);

  mask:=TBitmap.Create;
  mask.Monochrome:=true;
  mask.Height:=bmp.Height;
  mask.Width:=bmp.Width;
  mask.Canvas.Brush.Color:=clBlack;
  mask.Canvas.FillRect(mask.Canvas.ClipRect);
  for i:=mask.Height-1 downto 0 do BlockWrite(ico, mask.ScanLine[i]^, mask.Width div 8);
  mask.Destroy;

  CloseFile(ico);
end;
x128 вне форума Ответить с цитированием
Старый 27.07.2010, 21:18   #22
StartMis
Форумчанин
 
Регистрация: 21.04.2008
Сообщений: 175
По умолчанию

ага вот теперь работает.большое спасибо.

Последний раз редактировалось StartMis; 27.07.2010 в 22:08.
StartMis вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Bmp в ico AngelOfDeath Мультимедиа в Delphi 9 30.12.2008 06:21
PSD в ICO vinni Мультимедиа в Delphi 10 03.10.2008 16:52
Конвертация ICO в BMP DeDoK Общие вопросы Delphi 5 15.07.2008 23:44
Ico Zeraim Мультимедиа в Delphi 8 22.05.2008 09:11