错误、漏洞、问题 - 页 2063

 
有两个带有透明度通道的bmp对象。当它们相互重叠时,会产生一些uint颜色。如果我知道每个对象的叠加像素的uint-colours,我怎么能自己计算这些值?
 
fxsaber:
有两个带有透明度通道的bmp对象。当它们相互重叠时,会产生一些uint颜色。如果我知道每个对象的叠加像素的uint-colours,我怎么能自己计算这些值?

static uchar      GetA(const uint fromcolor){return(uchar((fromcolor)>>24));}
   static uchar      GetR(const uint fromcolor){return(uchar((fromcolor)>>16));}
   static uchar      GetG(const uint fromcolor){return(uchar((fromcolor)>>8));}
   static uchar      GetB(const uint fromcolor){return(uchar(fromcolor));}
static uint       ARGBToColor(const uchar a,const uchar r,const uchar g,const uchar b){return((a<<24)|(r<<16)|(g<<8)|(b));}

static uint cColor::Mix(const uint bottom,const uint top)
  {
//===============
// if top color is not transparent => no mixing required
//===============
   if(cColor::GetA(top)==UCHAR_MAX)return(top);
//===============

//===============
   static uint bottomprev=0;
   static uint topprev=0;
   static uint resultprev=0;
//===============

//===============
   if(bottomprev==bottom && topprev==top)return(resultprev);
//===============

//===============
   bottomprev=bottom;
   topprev=top;
//===============

//===============
// Get Params of Colors
//===============
   double topA=(double)cColor::GetA(top);   double bottomA=(double)cColor::GetA(bottom);
   double topR=(double)cColor::GetR(top);   double bottomR=(double)cColor::GetR(bottom);
   double topG=(double)cColor::GetG(top);   double bottomG=(double)cColor::GetG(bottom);
   double topB=(double)cColor::GetB(top);   double bottomB=(double)cColor::GetB(bottom);
//===============

//===============
// Blend components
//===============
   uchar newA=uchar(topA+(bottomA*(255.0-topA)/255.0));
   uchar newR=uchar((topR*topA/255.0)+(bottomR*bottomA *(255.0-topA)/(255.0*255.0)));
   uchar newG=uchar((topG*topA/255.0)+(bottomG*bottomA *(255.0-topA)/(255.0*255.0)));
   uchar newB=uchar((topB*topA/255.0)+(bottomB*bottomA *(255.0-topA)/(255.0*255.0)));
//===============

//===============
   resultprev=cColor::ARGBToColor(newA,newR,newG,newB);
//===============

//===============
// New Color
//===============
   return(resultprev);
//===============
  }
 
Andrey Barinov:

谢谢你!另一个问题。例如,如果有五个物体同时重叠,应该自下而上还是自上而下进行配对(上/下)?

 
fxsaber:

谢谢你!


最好是在同一画布上一次画出所有的(bmp)对象,从长远来看,这是一个更简单的方法。

 
Andrey Barinov:

最好是一次在一个画布上画出所有的(bmp)对象,从长远来看,这是个更简单的方法。

这就是我问的原因。以上是另一个问题。

 
fxsaber:

谢谢你!另一个问题。例如,如果有五个物体相互重叠,那么这些对子(上/下)应该从下往上画还是从上往下画?


我必须分层绘制,按顺序(Zorder),从下到上,因为我必须假设我不知道这五个物体的哪些像素会相交。就像在一块真正的画布上一样。

混合后,它看起来像这样


 
Andrey Barinov:

我按照顺序(如zorder)分层绘制,从底层到顶层,因为现在还不清楚这五个物体的哪些像素会重叠在一起。就像在一块真正的画布上一样。

混合起来后,你会得到这样的东西。

那很好啊!你是在使用CCanvas,还是全部由你自己解决?从长远来看,哪种方法更好?

 
fxsaber:

很好!你是在使用改良的CCanvas还是完全自己的解决方案?从长远来看,哪种方法更好?


我不得不自己写,但从标准库中 借用了大量的代码片段(原始的绘图算法、抗锯齿等)。把代码片断塞进我的图形工作概念中,结果是比把我的概念包裹在标准库中更容易。

如果标准库是 "活的",我不介意使用它,但到目前为止,它还没有以任何方式适应GUI。

 
Andrey Barinov:

我不得不自己写,但从标准库中 大量借用了一些代码(原始的绘图算法、抗锯齿等)。把代码片断塞进我的图形工作概念中,结果是比把我的概念包裹在标准库中更容易。

我不介意使用标准库,如果它是 "活的",但到目前为止,它还没有以任何方式适应GUI。

我现在明白了,谢谢你。

 
语言错误
#include <Expert\ExpertSignal.mqh>

void OnStart()
{
  CIndicator* a = NULL;   
  CExpertSignal b;
       
  b.InitIndicators(a); // 'InitIndicators' - no one of the overloads can be applied to the function call
}
原因: