资源文件可以加入png吗,delphi能操作png文件吗

TranceChow 2003-05-31 10:51:50
我要实现一个功能,要让图像背景透明,但是jpeg会损失颜色信息,透明不完全,所以想用png,或者image怎么实现有容差的透明
...全文
257 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
goomoo 2003-06-01
  • 打赏
  • 举报
回复
Alpha 融合位图

Alpha Blending 用来显示一个半透明的位图,该位图有完全透明或办透明的像素。

除了红、绿、兰通道之外,每个像素还有一个Alpha通道,......

<下面是源代码,自己看吧。>
Eastunfail 2003-06-01
  • 打赏
  • 举报
回复
资源文件什么都可以加~~~呵呵
TranceChow 2003-06-01
  • 打赏
  • 举报
回复
goomoo(古木)你的东西什么用阿
whitetiger8 2003-05-31
  • 打赏
  • 举报
回复
JPEG压缩也是有比例的!用PCX格式呢
goomoo 2003-05-31
  • 打赏
  • 举报
回复
Alpha blending a bitmap - Oct 28, 2002 - Technical Articles
Alpha blending is used to display an alpha bitmap, which is a bitmap that has transparent or semi-transparent pixels.
In addition to a red, green, and blue color channel, each pixel in an alpha bitmap has a transparency component known as its alpha channel. The alpha channel typically contains as many bits as a color channel. For example, an 8-bit alpha channel can represent 256 levels of transparency, from 0 (the entire bitmap is transparent) to 255 (the entire bitmap is opaque). Alpha blending mechanisms are invoked by calling AlphaBlend function. The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels. It is not supported on Microsoft Windows 95 or on versions of Microsoft Windows NT prior to Microsoft Windows 2000.

The following code sample divides a window into three horizontal areas. Then it draws an alpha-blended bitmap in each of the window areas.


const AC_SRC_ALPHA = $1;procedure DrawAlphaBlend (hWnd : HWND; hdcwnd : HDC);var Ahdc : HDC; // handle of the DC we will create bf : BLENDFUNCTION; // structure for alpha blending Ahbitmap : HBITMAP; // bitmap handle bmi : BITMAPINFO; // bitmap header pvBits : pointer; // pointer to DIB section ulWindowWidth, ulWindowHeight : ULONG; // window width/height ulBitmapWidth, ulBitmapHeight : ULONG; // bitmap width/height rt : TRect; // used for getting window dimensionsbegin // get window dimensions GetClientRect(hWnd, rt); // calculate window width/height ulWindowWidth := rt.right - rt.left; ulWindowHeight := rt.bottom - rt.top; // make sure we have at least some window size if ((ulWindowWidth = 0 ) and (ulWindowHeight=0)) then exit; // divide the window into 3 horizontal areas ulWindowHeight := trunc(ulWindowHeight / 3); // create a DC for our bitmap -- the source DC for AlphaBlend Ahdc := CreateCompatibleDC(hdcwnd); // zero the memory for the bitmap info ZeroMemory(@bmi, sizeof(BITMAPINFO));bmi.bmiHeader.biSize := sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth := trunc(ulWindowWidth - (ulWindowWidth/5)*2); ulBitmapWidth := trunc(ulWindowWidth - (ulWindowWidth/5)*2); bmi.bmiHeader.biHeight := trunc(ulWindowHeight - (ulWindowHeight/5)*2); ulBitmapHeight := trunc(ulWindowHeight - (ulWindowHeight/5)*2); bmi.bmiHeader.biPlanes := 1; bmi.bmiHeader.biBitCount := 32; // four 8-bit components bmi.bmiHeader.biCompression := BI_RGB; bmi.bmiHeader.biSizeImage := ulBitmapWidth * ulBitmapHeight * 4; // create our DIB section and select the bitmap into the dc Ahbitmap := CreateDIBSection(Ahdc, bmi, DIB_RGB_COLORS, pvBits, 0, 0); SelectObject(Ahdc, Ahbitmap); bf.BlendOp := AC_SRC_OVER; bf.BlendFlags := 0; bf.SourceConstantAlpha := $7f; // half of 0xff = 50% transparency bf.AlphaFormat := 0; // ignore source alpha channel AlphaBlend(hdcwnd, trunc(ulWindowWidth/5), trunc(ulWindowHeight/5), ulBitmapWidth, ulBitmapHeight, Ahdc, 0, 0, ulBitmapWidth, ulBitmapHeight, bf); bf.BlendOp := AC_SRC_OVER; bf.BlendFlags := 0; bf.AlphaFormat := AC_SRC_ALPHA; // use source alpha bf.SourceConstantAlpha := $ff; // opaque (disable constant alpha) AlphaBlend(hdcwnd, trunc(ulWindowWidth/5), trunc(ulWindowHeight/5+ulWindowHeight), ulBitmapWidth, ulBitmapHeight, Ahdc, 0, 0, ulBitmapWidth, ulBitmapHeight, bf); bf.BlendOp := AC_SRC_OVER; bf.BlendFlags := 0; bf.AlphaFormat := 0; bf.SourceConstantAlpha := $3A; AlphaBlend(hdcwnd, trunc(ulWindowWidth/5), trunc(ulWindowHeight/5+2*ulWindowHeight), ulBitmapWidth, ulBitmapHeight, Ahdc, 0, 0, ulBitmapWidth, ulBitmapHeight, bf); // do cleanup DeleteObject(Ahbitmap); DeleteDC(Ahdc);end;

耙子 2003-05-31
  • 打赏
  • 举报
回复
png 可能不支持。jpeg 也可以做到无损压缩。

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧