Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.09.23;
Скачать: CL | DM;

Вниз

наложение BitMap a на BitMap   Найти похожие ветки 

 
esyes   (2006-12-13 00:40) [0]

Здравствуйте.
Есть 2 битмапа.
На 2ом битмапе(который требуется наложить) есть участки белого цвета. Так нужно сделать так, чтобы при наложении этот участок был прозрачным. Т.е. в итоге должно получиться изображение, в котором - все из 2го битмапа, но на местах белых пятен - изображение 1го битмапа.
Подскажите реализацию.
С уважением.
Огромное спасибо!


 
oxffff ©   (2006-12-13 00:48) [1]

GDI
BitBlt или StretchBlt.

или поищи в GDI+

Вообщем MSDN тебе в помощь


 
Eraser ©   (2006-12-13 01:09) [2]

> [0] esyes   (13.12.06 00:40)

TransparentBlt + F1


 
DVM ©   (2006-12-13 10:16) [3]

procedure DrawBitmapTransparent(dc: HDC;
                               hBitmap: HBITMAP;
                               xStart, yStart: integer;
                               colorTransparent: COLORREF); stdcall;
var
 bm: BITMAP;
 hdcMem: HDC;
 ptSize, ptOrg: TPoint;
begin
 if dc <> 0 then
   begin
     hdcMem := CreateCompatibleDC(dc);
     if (hdcMem <> 0) and (hBitmap <> 0) then
       begin
         SelectObject(hdcMem, hBitmap);
         SetMapMode(hdcMem, GetMapMode(dc));
         GetObject(hBitmap, sizeof(BITMAP), @bm);
         ptSize.x := bm.bmWidth;
         ptSize.y := bm.bmHeight;
         DPtoLP(dc, ptSize, 1);
         ptOrg.x := 0;
         ptOrg.y := 0;
         DPtoLP(hdcMem, ptOrg, 1);
         TransparentBlt(dc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, ptOrg.x, ptOrg.y, colorTransparent);
         DeleteDC(hdcMem);
       end;
   end;
end;


 
antonn ©   (2006-12-13 21:30) [4]

procedure CopyBitmapTr24to24red(_B_in,_B_out:Tbitmap; _x,_y:integer);
const
 MaxPixelCount = MaxInt div SizeOf(TRGBTriple);
type
 PRGBArray = ^TRGBArray;
 TRGBArray = array[0..MaxPixelCount-1] of TRGBTriple;
var x, y, x_cor,y_cor,x_corS,y_corS,
   w_in,h_in,w_out,h_out,tmp: Integer;
   RowOut: PRGBArray; RowIn: PRGBArray;
begin
w_in:=_B_in.Width;
h_in:=_B_in.Height;
w_out:=_B_out.Width;
h_out:=_B_out.Height;
if (_x)>w_out-1 then exit; if (_x+w_out)<0 then exit;
if (_y)>h_out-1 then exit; if (_y+h_out)<0 then exit;

 if _x<0 then x_corS:=abs(_x) else x_corS:=0;
 if _y<0 then y_corS:=abs(_y) else y_corS:=0;
 if (_x+w_in)>w_out then x_cor:=_x+w_in-w_out else x_cor:=0;
 if (_y+h_in)>h_out then y_cor:=_y+h_in-h_out else y_cor:=0;

 y_cor:=h_in-1-y_cor;
 tmp:=w_in-1-x_cor;
 for y:=y_corS to y_cor do begin
    RowOut:= _B_out.ScanLine[y+_y];
    RowIn:= _B_in.ScanLine[y];
   for x:=x_corS to tmp do
    if not((RowIn[x].rgbtRed=255)and(RowIn[x].rgbtGreen=255)and(RowIn[x].rgbtBlue=25 5)) then begin
         RowOut[x+_x].rgbtBlue:=RowIn[x].rgbtBlue;
         RowOut[x+_x].rgbtGreen:=RowIn[x].rgbtGreen;
         RowOut[x+_x].rgbtRed:=RowIn[x].rgbtRed;
   end;
 end
end;


_B_in - накладываемый битмап
_B_out - основа
_x,_y - координаты наложения

в выделенной строке указаны проверки на цвет, который будет прозрачный (например, красный - 255,0,0)


 
antonn ©   (2006-12-13 21:31) [5]

+[4]
битмапы должны быть 24 битные (сделать им Bitmap.pixelformat:=pf24bit;)



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

Текущий архив: 2007.09.23;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.018 c
15-1187951223
palva
2007-08-24 14:27
2007.09.23
Индикатор настоящего программиста


15-1188267255
Slider007
2007-08-28 06:14
2007.09.23
С днем рождения ! 28 августа 2007 вторник


15-1187882160
Joan
2007-08-23 19:16
2007.09.23
SQL


15-1187936776
palva
2007-08-24 10:26
2007.09.23
Конференция Начинающим


2-1188485653
пАзер
2007-08-30 18:54
2007.09.23
изменение рисунка рабочего стола