Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Как сделать необычную ФОРМУ с TImage-ем? [D7, WinXP]


Lamer666 ©   (2007-12-09 10:11:00) 

Добрый день!
В общем сделал форму на ней Image разместил, как мне спрятать форму, чтобы при запуске был виден только мой IMAGE?
Спасибо!


Вредитель   (2007-12-11 11:26:00) [1]

Зачем все эти  HRGN, просто:
Borderstyle:=bsNone;
image1.transparent:=true;
transparentcolor:=true;
transparentcolorvalue:=clBlack;
color:=clblack;


Lamer666   (2007-12-09 17:32:00) [2]


> Nucer

СПАСИБО БОЛЬШОЕ!


Lamer666   (2007-12-09 12:18:00) [3]


> CurrentColor, TransColor: TColor;

Ой извини! : ))


Nucer   (2007-12-09 12:15:00) [4]

В раздел var посмотри =)

var
TmpRgn: HRGN;
x, y: integer;
ConsecutivePixels: integer;
CurrentPixel: TColor;
CurrentColor, TransColor: TColor;
Result: HRGN;
Image:TBitmap;


Lamer666   (2007-12-09 12:04:00) [5]

Извини, я имел ввиду, чье это свойство?
Уменя ругаеться приложение?


Nucer   (2007-12-09 12:02:00) [6]

Прозрачный цвет


Lamer666   (2007-12-09 11:56:00) [7]


> TransColor:=Image.Canvas.Pixels[0,0];

Что такое? : )


Nucer   (2007-12-09 11:41:00) [8]

procedure TForm1.SetBitmapRgn(bmp:string);
var
 TmpRgn: HRGN;
 x, y: integer;
 ConsecutivePixels: integer;
 CurrentPixel: TColor;
 CurrentColor, TransColor: TColor;
 Result: HRGN;
 Image:TBitmap;

begin
Image:=TBitmap.Create;
Image.LoadFromFile(bmp);

 Result := CreateRectRgn(0, 0, Image.Width, Image.Height);

 if (Image.Width = 0) or (Image.Height = 0) then exit;
 TransColor:=Image.Canvas.Pixels[0,0];

 for y := 0 to Image.Height - 1 do
   begin
   CurrentColor := Image.Canvas.Pixels[0,y];
   ConsecutivePixels := 1;
   for x := 0 to Image.Width - 1 do
     begin
     CurrentPixel := Image.Canvas.Pixels[x,y];

     if CurrentColor = CurrentPixel
       then inc(ConsecutivePixels)
       else begin
            if CurrentColor = TransColor then
              begin
              TmpRgn := CreateRectRgn(x-ConsecutivePixels, y, x, y+1);
              CombineRgn(Result, Result, TmpRgn, RGN_DIFF);
              DeleteObject(TmpRgn);
              end;
            CurrentColor := CurrentPixel;
            ConsecutivePixels := 1;
            end;
     end;

  if (CurrentColor = TransColor) and (ConsecutivePixels > 0) then
     begin
     TmpRgn := CreateRectRgn(x-ConsecutivePixels, y, x, y+1);
     CombineRgn(Result, Result, TmpRgn, RGN_DIFF);
     DeleteObject(TmpRgn);
     end;
   end;

SetWindowRgn(Self.Handle, Result, True);
Image.Free;
end;


Наверх

Титульная страница Поиск, карта сайта Написать письмо