首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AggPas Delphi绘图透明度

AggPas Delphi绘图透明度
EN

Stack Overflow用户
提问于 2010-07-18 18:33:47
回答 2查看 1.1K关注 0票数 2

我想做什么

我有一个绘图过程(它有效),它绘制到一个位图" OBJmap“,然后将OBJmap放入Wholemap。这一切都是可行的,但有一个问题。它似乎将objmap中未定义的部分视为白色,尽管objmap和整体性地图被设置为PF32Bit,因此当它将objmap放入整个地图中时,我会在粘贴的图像后面得到一个应该是透明的白色框。

这只发生在ATI机器上,但这是针对学校的,它们都有100%的ati,因为它们很便宜(我不是偏见诚实的),所以建议我使用AggPas来解决这个问题。

我的代码

代码语言:javascript
复制
procedure DrawScene();
var
  ObjLength,LineLength,Filllength,Obj,lin,angle,i,x1,y1,x2,y2:integer;
  Npoints : array[0..1] of Tpoint;
  WG,OG: Tagg2d;

  Objmap,wholemap:TBitmap;
begin
  //Set up WholeMap Bitmap
  wholemap := TBitmap.Create;
  wholemap.PixelFormat:=pf32bit;
  wholemap.Transparent:=false;
  wholemap.Width:=area;
  wholemap.height:=area;

  WG:= Tagg2d.create;
  BitmapAlphaTransparency(wholemap, 0);
  WG.attach(wholemap,False);
  WG.ClearAll(255,0,0,255);
  //BitmapAlphaTransparency(wholemap, 255);

  //WG.MasterAlpha(255);

  // itterate through each object drawing the object to OBJmap
  ObjLength:=length(Objects);
  for Obj:=0 to (ObjLength-1) do
  if objects[Obj].Visible then
  begin
    //Set up Object map Bitmap
    Objmap := TBitmap.Create;
    Objmap.PixelFormat:=pf32bit;

    Objmap.Transparent:=true;
    Objmap.Width:=Objects[obj].Boundright-objects[obj].Boundleft+3;
    Objmap.height:=Objects[obj].BoundTop-objects[obj].Boundbottom+3;

    OG:= Tagg2d.create;
    OG.attach(Objmap,False);

    {OG.ClearAll(0,0,255,255);  // Clears all bitmap to transparrent
    OG.MasterAlpha(255);
    OG.LineWidth(5);
    og.AntiAliasGamma(255);
    OG.
    OG.LineColor(0,255,0,255);
    OG.FillColor(0,255,0,255);
    //OG.
    OG.MoveTo(0,0);
    OG.LineTo(Objmap.width-1,Objmap.height-1); }

    //Draw the Lines to Objmap
    LineLength:=length(objects[Obj].Lines)-1;
    angle:=objects[Obj].Rotation;
    for lin:=0 to (LineLength) do
    begin
      //Transform points
      for i:=0 to 1 do
        Npoints[i] := PointAddition(RotatePoint(objects[obj].Lines[lin].Point[i],angle),point(-objects[obj].boundleft,-Objects[obj].Boundbottom),false);
      //draw transformed points
      Objmap:=DrawLine(Npoints[0].x,Npoints[0].y,Npoints[1].x,Npoints[1].y,objects[obj].Lines[lin].Color,Objmap,OG);
    end;
    //Draw the Fills to Objmap
    Filllength:=length(objects[Obj].Fills)-1;
    for i:=0 to Filllength do
    begin
      //transform points
      Npoints[0]:=PointAddition(RotatePoint(objects[Obj].Fills[i].Point,objects[Obj].Rotation),point(-objects[obj].boundleft,-Objects[obj].Boundbottom),false);
      // fill points
      Objmap:=fillpoint( Npoints[0].x, Npoints[0].y,objects[Obj].Fills[i].color,Objmap);
    end;

    //draw objmap to wholemap
    x1:=objects[obj].Position.x+objects[obj].Boundleft-1;
    y1:=area-(objects[obj].Position.y+objects[obj].Boundtop)-2;
    x2:=x1+Objmap.Width;
    y2:=y1+Objmap.Height;

    WG.TransformImage(Objmap,x1,y1,x2,y2);  //this show border
    //WG.copyimage(Objmap,x1,y1);  //this draws the scene up but does not handle transparencies correctly
    //wholemap.Canvas.Draw(x1,y1,Objmap);//does not work in PF32bit or on ati machines


    //wg.Free; // this it does not like (crash) do i need it?
    Objmap.Free;
  end;


   // write wholemap to Visible Canvas
   mainwindow.bufferim.Canvas.Draw(0,0,wholemap);
   wholemap.Free;
   mainwindow.RobotArea.Picture.Graphic:=mainwindow.bufferim.Picture.Graphic;
end;

图像示例

不工作,不工作

我只能在默认的Nvidia机器上获得工作结果。

代码语言:javascript
复制
wholemap.Canvas.Draw

方法,我希望它能够在所有使用aggpass的机器上工作。

我该怎么做?如何在全地图上绘制讣告,而不是绘制透明的比特?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-06 16:09:58

我也有同样的问题,您需要在调用Transform之前设置BlendMode

代码语言:javascript
复制
WG.BlendMode(AGG_BlendSrcTop);

这对我有效,但你可能需要尝试几个混合模式,然后才能得到正确的答案。

票数 2
EN

Stack Overflow用户

发布于 2010-07-19 07:42:40

尝试BitmapAlphaTransparency(整体性地图,0);在WG.attach之前。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3276733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档