Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2008.08.31;
Скачать: [xml.tar.bz2];

Вниз

Как сделать необычную ФОРМУ с TImage-ем?   Найти похожие ветки 

 
Lamer666   (2007-12-09 10:11) [0]

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


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

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;


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


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

Что такое? : )


 
Nucer   (2007-12-09 12:02) [3]

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


 
Lamer666   (2007-12-09 12:04) [4]

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


 
Nucer   (2007-12-09 12:15) [5]

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

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


 
Lamer666   (2007-12-09 12:18) [6]


> CurrentColor, TransColor: TColor;

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


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


> Nucer

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


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

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



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2008.08.31;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.005 c
2-1216790670
vegarulez
2008-07-23 09:24
2008.08.31
Можно ли управлять вольтажом USB порта?


6-1191317704
Obsidee
2007-10-02 13:35
2008.08.31
TSocketServer без формы


15-1215679351
Никитич
2008-07-10 12:42
2008.08.31
Посоветуйте книгу по C#


2-1216808609
Тоша
2008-07-23 14:23
2008.08.31
TMemoryStream


6-1192701219
Tonich
2007-10-18 13:53
2008.08.31
Indy SendCmd





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский