Home > Back-end >  Please everyone a great god, and how to use for synthesis of transparent mask bitmap images?
Please everyone a great god, and how to use for synthesis of transparent mask bitmap images?

Time:10-01

Images 1, for example, add pictures 2 (mask), how to get the effect of the 3 picture? Picture 3 is just a display in the middle, surrounded by transparent or translucent, so you can get a smooth edge of picture effect,

Request the great god can grant instruction, best can have a code, thank you!





CodePudding user response:

Forgot to say, what I use is delphi7, thank humbly you becoming

CodePudding user response:

BitBlt function, twice, the first draw pictures with srcCopy parameters correctly, the second drawing mask images, with srcand with it

CodePudding user response:

Bitblt (image3. Picture. Bitmap. Canvas. Handle, 0, 0, 23, 22, image1. The Picture. The Bitmap. The Canvas, Handle, 0, 0, SRCCOPY);

Bitblt (image3. Picture. Bitmap. Canvas. Handle, 0, 0, 23, 22, image2. The Picture. The Bitmap. The Canvas, Handle, 0, 0, SRCAND);

Image3. Refresh;

Can you tell me isn't it? But there is no effect,
Use bitblt all sorts of way has been tried and have the desired effect,

This mask figure, figure 1 should be according to the color of figure 2, figure 2 is black, if the corresponding pixels from figure 1, transparent, grey, translucent, according to the grey value decision transparent degree?

CodePudding user response:

refer to the second floor suiyunonghen response:
function BitBlt, twice, first draw pictures with srcCopy parameters correctly, the second drawing mask images, with srcand and the
thank you for your advice, but I tried many times, can't ah, I wonder if there are no other ways?

CodePudding user response:

http://hi.baidu.com/aclshysmtfbdefd/item/3b68780175fd5beb3599029b

CodePudding user response:

Use GDI +, draw the background, and then draw the bitmap,

Var
I, the Count: Integer;
That TClsid;
Image: TGpImage;
BkImage: TGpImage;
Attr: TGpImageAttributes;
BMP: TGpBitmap;
TMP: TGpBitmap;
Tg, bg: TGpGraphics;
GUID: TGUID;
The begin
//open the image file
Image:=TGpImage. Create (' e: \ 01. PNG ');
BkImage:=TGpImage. Create (' e: \ bk PNG ');
TMP:=TGpBitmap. Create (Image. The Width of the Image. The Height, pf32bppARGB);
Tg:=TGpGraphics. Create (TMP);
BMP:=TGpBitmap. Create (Image. The Width of the Image. The Height, pf32bppARGB);
Bg:=TGpGraphics. Create (BMP);
Attr:=TGpImageAttributes. Create;
Try
//set transparent color range
Attr. SetColorKey ($FFffffff, $FFffffff);
Image. GetFrameDimensionsList (@ GUID, 1);
//gets image shot number
Count:=Image. GetFrameCount (GUID);
GetEncoderClsid (' image/PNG, clsids);

For I:=0 to do the Count - 1
The begin
//select activate shot
Image. SelectActiveFrame (GUID, I);
//draw the current shot to the temporary
Tg. DrawImage (Image, 0, 0, the Image Width, Image, Height);
//composite image initialized to transparent color
Bg. The Clear (0);
Background//picture, if you don't need background, the following can be commented out
Bg. DrawImage (BkImage, 0, 0, BMP. Width, BMP, Height);
//draw temporary
Bg. DrawImage (TMP, GpRect (0, 0, BMP. Width, BMP, Height),
0, 0, TMP. Width, TMP. Height, utPixel, Attr);
//save
BMP. Save (' e: \ 01 - '+ IntToStr (I) +' PNG ', clsids);
end;
The finally
Attr. Free;
Bg. Free;
BMP. Free;
Tg. Free;
TMP. Free;
BkImage. Free;
Image. Free;
end;

CodePudding user response:

2 times than with or NotXOR

CodePudding user response:

refer to 7th floor zhzhrony response:
2 times than with or NotXOR


The exclusive or
  • Related