本文整理汇总了C++中Surface::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ Surface::Format方法的具体用法?C++ Surface::Format怎么用?C++ Surface::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface::Format方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
bool Render(const RenderTarget &inTarget, const RenderState &inState)
{
Surface *s = mFill->bitmapData;
double bmp_scale_x = 1.0/s->Width();
double bmp_scale_y = 1.0/s->Height();
// Todo:skew
bool is_stretch = (inState.mTransform.mMatrix->m00!=1.0 ||
inState.mTransform.mMatrix->m11!=1.0) &&
( inState.mTransform.mMatrix->m00 > 0 &&
inState.mTransform.mMatrix->m11 > 0 );
for(int i=0; i<mTileData.size(); i++)
{
TileData &data= mTileData[i];
BlendMode blend = data.mHasColour ? ( mBlendMode==bmAdd ? bmTintedAdd : bmTinted ):
mBlendMode;
UserPoint corner(data.mPos);
UserPoint pos = inState.mTransform.mMatrix->Apply(corner.x,corner.y);
if (s->Format()==pfAlpha && !is_stretch && mBlendMode==bmNormal && data.mHasColour /* integer co-ordinate?*/ )
{
unsigned int col = inState.mColourTransform->Transform(data.mColour|0xff000000);
s->BlitTo(inTarget, data.mRect, (int)(pos.x), (int)(pos.y), blend, 0, col);
}
else if ( (is_stretch || data.mHasTrans) )
{
// Can use stretch if there is no skew and no colour transform...
if (!data.mHasColour && (!data.mHasTrans) && mBlendMode==bmNormal )
{
UserPoint p0 = pos;
pos = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y+data.mRect.h);
s->StretchTo(inTarget, data.mRect, DRect(p0.x,p0.y,pos.x,pos.y,true));
}
else
{
int tile_alpha = 256;
bool just_alpha = (data.mHasColour) &&
((data.mColour&0x00ffffff ) == 0x00ffffff);
if (data.mHasColour && mBlendMode==bmNormal)
{
tile_alpha = data.mColour>>24;
if (tile_alpha>0) tile_alpha++;
}
// Create alpha mask...
UserPoint p[4];
p[0] = inState.mTransform.mMatrix->Apply(corner.x,corner.y);
if (data.mHasTrans)
{
p[1] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.w*data.mTransX.x,
corner.y + data.mRect.w*data.mTransY.x);
p[2] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.w*data.mTransX.x + data.mRect.h*data.mTransX.y,
corner.y + data.mRect.w*data.mTransY.x + data.mRect.h*data.mTransY.y );
p[3] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.h*data.mTransX.y,
corner.y + data.mRect.h*data.mTransY.y );
}
else
{
p[1] = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y);
p[2] = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y+data.mRect.h);
p[3] = inState.mTransform.mMatrix->Apply(corner.x,corner.y+data.mRect.h);
}
Extent2DF extent;
extent.Add(p[0]);
extent.Add(p[1]);
extent.Add(p[2]);
extent.Add(p[3]);
// Get bounding pixel rect
Rect rect = inState.mTransform.GetTargetRect(extent);
// Intersect with clip rect ...
Rect visible_pixels = rect.Intersect(inState.mClipRect);
if (!visible_pixels.HasPixels())
continue;
Rect alpha_rect(visible_pixels);
bool offscreen_buffer = mBlendMode!=bmNormal;
if (offscreen_buffer)
{
for(int i=0; i<4; i++)
{
p[i].x -= visible_pixels.x;
p[i].y -= visible_pixels.y;
}
alpha_rect.x -= visible_pixels.x;
alpha_rect.y -= visible_pixels.y;
}
int aa = 1;
SpanRect *span = new SpanRect(alpha_rect,aa);
for(int i=0; i<4; i++)
span->Line00(
Fixed10( p[i].x, p[i].y ),
Fixed10( p[(i+1)&3].x, p[(i+1)&3].y) );
//.........这里部分代码省略.........
示例2: Render
//.........这里部分代码省略.........
tile_alpha = data.mColour>>24;
if (tile_alpha>0) tile_alpha++;
}
// Create alpha mask...
UserPoint p[4];
p[0] = inState.mTransform.mMatrix->Apply(corner.x,corner.y);
if (data.mHasTrans)
{
p[1] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.w*data.mTransX.x,
corner.y + data.mRect.w*data.mTransY.x);
p[2] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.w*data.mTransX.x + data.mRect.h*data.mTransX.y,
corner.y + data.mRect.w*data.mTransY.x + data.mRect.h*data.mTransY.y );
p[3] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.h*data.mTransX.y,
corner.y + data.mRect.h*data.mTransY.y );
}
else
{
p[1] = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y);
p[2] = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y+data.mRect.h);
p[3] = inState.mTransform.mMatrix->Apply(corner.x,corner.y+data.mRect.h);
}
Extent2DF extent;
extent.Add(p[0]);
extent.Add(p[1]);
extent.Add(p[2]);
extent.Add(p[3]);
// Get bounding pixel rect
Rect rect = inState.mTransform.GetTargetRect(extent);
// Intersect with clip rect ...
Rect visible_pixels = rect.Intersect(inState.mClipRect);
if (!visible_pixels.HasPixels())
continue;
Rect alpha_rect(visible_pixels);
bool offscreen_buffer = mBlendMode!=bmNormal;
if (offscreen_buffer)
{
for(int i=0;i<4;i++)
{
p[i].x -= visible_pixels.x;
p[i].y -= visible_pixels.y;
}
alpha_rect.x -= visible_pixels.x;
alpha_rect.y -= visible_pixels.y;
}
int aa = 1;
SpanRect *span = new SpanRect(alpha_rect,aa);
// ToImageAA - add 0.5 offset
for(int i=0;i<4;i++)
span->Line00(
Fixed10( p[i].x + 0.5, p[i].y + 0.5 ),
Fixed10( p[(i+1)&3].x + 0.5, p[(i+1)&3].y + 0.5) );
AlphaMask *alpha = span->CreateMask(inState.mTransform,tile_alpha);
delete span;
float uvt[6];
uvt[0] = (data.mRect.x) * bmp_scale_x;
uvt[1] = (data.mRect.y) * bmp_scale_y;
uvt[2] = (data.mRect.x + data.mRect.w) * bmp_scale_x;
uvt[3] = (data.mRect.y) * bmp_scale_y;
uvt[4] = (data.mRect.x + data.mRect.w) * bmp_scale_x;
uvt[5] = (data.mRect.y + data.mRect.h) * bmp_scale_y;
mFiller->SetMapping(p,uvt,2);
// Can render straight to surface ....
if (!offscreen_buffer)
{
if (s->Format()==pfAlpha)
{
if (data.mHasColour)
{
ARGB col = inState.mColourTransform->Transform(data.mColour|0xff000000);
mFiller->SetTint(col);
}
mFiller->Fill(*alpha,0,0,inTarget,inState);
}
else if (data.mHasTrans && !just_alpha)
{
ColorTransform buf;
RenderState col_state(inState);
ColorTransform tint;
tint.redMultiplier = ((data.mColour) & 0xff) * one_on_255;
tint.greenMultiplier = ((data.mColour>>8) & 0xff) * one_on_255;
tint.blueMultiplier = ((data.mColour>>16) & 0xff) * one_on_255;
col_state.CombineColourTransform(inState, &tint, &buf);
mFiller->Fill(*alpha,0,0,inTarget,col_state);
}
else
mFiller->Fill(*alpha,0,0,inTarget,inState);
}
else
{