两个BMP图像叠加,怎么设置透明度灰度值等使得两个图象看的都比较清晰?任何图象格式的都可以

解决方案 »

  1.   

    有这样的算法满足你的要求吗?一般 对应象素点,对应RGB风量,v = (v1+v2) / 2 ,v1 v2 的权重就可以调,勉强算你的透明度。
      

  2.   

    直接RGB百分比加
    如R = R1 * 20% + R2 * 80%
      

  3.   

    以下是从一个源码中copy下来的:...
    girl = (HBITMAP)LoadImage(NULL,"girl.bmp",IMAGE_BITMAP,298,329,LR_LOADFROMFILE); 
    GetObject(girl,sizeof(BITMAP),&bm2);
    px2 = new unsigned char [bm2.bmHeight * bm2.bmWidthBytes];
    GetBitmapBits(girl,bm2.bmHeight * bm2.bmWidthBytes,px2); int xend,yend;
    int x,y,i; //癹伴ノ跑计
    int rgb_b;
    int PxBytes = bm1.bmBitsPixel / 8 ; xend = xstart + 298;
    yend = ystart + 329; //矪瞶璉春瓜钩肅︹
    for(y=ystart;y<yend;y++) 
    {
    for(x=xstart;x<xend;x++) 
    {
    rgb_b = y * bm1.bmWidthBytes + x * PxBytes ; px1[rgb_b] = px1[rgb_b] * 0.7;
    px1[rgb_b+1] = px1[rgb_b+1] * 0.7;
    px1[rgb_b+2] = px1[rgb_b+2] * 0.7;
    }
    } //矪瞶玡春瓜钩肅︹
    for(y=0;y<(bm2.bmHeight); y++) 
    {
    for(x=0;x<bm2.bmWidth; x++) 
    {
    rgb_b = y * bm2.bmWidthBytes + x * PxBytes ;
    i = (ystart+y) * bm1.bmWidthBytes + (xstart+x) * PxBytes; px2[rgb_b]   = px2[rgb_b]  *0.3 + px1[i];
    px2[rgb_b+1] = px2[rgb_b+1] *0.3 + px1[i+1];
    px2[rgb_b+2] = px2[rgb_b+2] *0.3 + px1[i+2];
    }
    } SetBitmapBits(girl,bm2.bmHeight*bm2.bmWidthBytes,px2);
    ...
    看上去和2楼说得方法一样,乘以百分比.效果不错.2幅图都能看清楚.
      

  4.   

    设定2个透明度参数:C1,C2
    C1+C2=1
    按照
    (R,G,B)=C1(R1,G1,B1)+C2(R2,G2,B2)计算合成的象素。