MMX 一次性清楚黑色需要怎么样? 麻烦高手来帮帮忙忙。很急~! 我的游戏登陆器一般都是DX来图象处理,会照成卡。所以需要改进。但是MMX去除黑色的函数不太会~!

解决方案 »

  1.   

    没明白LZ意思,黑色本就是R、G、B都为0,还要怎样清除呢?
    如果是用DX处理,可直接用IDirectDrawSurface.SetColorKey设置关键色为黑色
      

  2.   


    这是我游戏的用MMX但是我不懂怎么过滤掉黑色  所以想叫你帮忙怎么过滤掉黑色。 我现在的登陆器是DX ,但是会卡。我现在想用MMX来处理。
    你应该明白的。
        其实就是需要怎么用MMX来调用函数过滤掉黑色
      

  3.   

    procedure DrawBlendEx (dsuf: TDirectDrawSurface; x, y: integer; ssuf: TDirectDrawSurface; ssufleft, ssuftop, ssufwidth, ssufheight, blendmode: integer);
    var
       sddsd, dddsd: TDDSurfaceDesc;
       sptr, dptr: PWord;
       srcwidth, srctop, srcbottom, srcleft: Integer;
       DstX, DstY: Integer;      // X/Y 方向的计数器
    begin
       if (dsuf.canvas = nil) or (ssuf.canvas = nil) then Exit;
       if x >= dsuf.Width then exit;
       if y >= dsuf.Height then exit;
       if x < 0 then begin
          srcleft := -x;
          srcwidth := ssufwidth + x;
          x := 0;
       end else begin
          srcleft := ssufleft;
          srcwidth := ssufwidth;
       end;
       if y < 0 then begin
          srctop := -y;
          srcbottom := ssufheight;
          y := 0;
       end else begin
          srctop := ssuftop;
          srcbottom := srctop + ssufheight;
       end;
       if srcleft + srcwidth > ssuf.Width then srcwidth := ssuf.Width-srcleft;
       if srcbottom > ssuf.Height then srcbottom := ssuf.Height;
       if x + srcwidth > dsuf.Width then srcwidth := (dsuf.Width-x) div 4 * 4;
       if y + srcbottom - srctop > dsuf.Height then srcbottom := dsuf.Height-y+srctop;
       if (x+srcwidth) * (y+srcbottom-srctop) > dsuf.Width * dsuf.Height then srcbottom := srctop + (srcbottom-srctop) div 2;   if (srcwidth <= 0) or (srcbottom <= 0) or (srcleft >= ssuf.Width) or (srctop >= ssuf.Height) then exit;
       if srcWidth > SCREENWIDTH + 100 then exit;
        if ssuf.Height > 350 then begin
           //TfrmMain.DScreen.AddChatBoardString('test; ' + InttoStr(srcwidth) + ' ' + InttoStr(srcbottom) + ' ' + InttoStr(srctop),clWhite, clBlack);
           end;
       try
          sddsd.dwSize := SizeOf(sddsd);
          dddsd.dwSize := SizeOf(dddsd);
          ssuf.Lock (TRect(nil^), sddsd);
          dsuf.Lock (TRect(nil^), dddsd);      for DstY:=srctop to srcbottom-1 do begin
             sptr := PWord(integer(sddsd.lpSurface) + sddsd.lPitch * DstY + srcleft * 2);
             dptr := PWord(integer(dddsd.lpSurface) + (y+DstY-srctop) * dddsd.lPitch + x * 2);        for DstX := 0 to srcwidth - 1 do begin
              if sptr^>0 then
              if BlendMode = 0 then begin
              dptr^ := ColorConversion(dptr^, sptr^);
              //dptr^ := Color256Mix[dptr^][sptr^]
              end else begin
              dptr^ := ColorConversion(dptr^ , sptr^);
             // dptr^ := Color256Anti[dptr^][sptr^];
              end;
              //DstP:=PDWord(integer(dptr)+2);
              //SrcP:=PDWord(integer(sptr)+2);
              Inc(dptr);
              Inc(sptr);
            end;
          end;   finally
          ssuf.UnLock();
          dsuf.UnLock();
       end;
    end;function ColorConversion(DstP, SrcP: Integer): Integer;
    var
      a1,a2,a3:byte;
      b1,b2,b3:byte;
    begin
       { if DstP=$FFFFFFF then
           DstP:=0
         else begin
           a1:=_Min(255,round((DstP shr 16)));
           a2:=_Min(255,round(((DstP and $FF00) shr 8)));
           a3:=_Min(255,round((DstP and $FF)));
           DstP:=(a1 shl 16) or (a2 shl 8) or a3;
          end;
        if SrcP=$FFFFFFF then
           SrcP:=0
         else begin
           b1:=_Min(255,round((SrcP shr 16)));
           b2:=_Min(255,round(((SrcP and $FF00) shr 8)));
           b3:=_Min(255,round((SrcP and $FF)));
           SrcP:=(b1 shl 16) or (b2 shl 8) or b3;
      end;     }
      // result := DstP div 2 + SrcP div 2;
        // if SrcP=$FFFFFFF then SrcP:=0;
        // if DstP=$FFFFFFF then DstP:=0;
         if SrcP in [0,15,16,18,73] then SrcP:=$FFFF;
         if DstP in [0,15,16,18,73] then DstP:=$FFFF;
         result := SrcP;
       //if SrcP > DstP div 2 then result := SrcP else result := DstP or SrcP;
      // if (SrcP in [0,15,16,18,73]) or (DstP in [0,15,16,18,73]) then {result := DstP} else result := SrcP;
      // if SrcP = $00050505 then result := DstP else result := SrcP;
    end;