【问题标题】:Custom Drawing of Alpha ImagesAlpha 图像的自定义绘图
【发布时间】:2011-07-11 08:00:35
【问题描述】:

我正在尝试对图像进行自定义绘图(使用 alpha),并最终对其应用不同的颜色。现在我只是想正确地绘制它。这可能是一个简单的问题,但结果是我的图像上的 ALPHA 是黑色的。图片是从 Photoshop 创建的具有正确 alpha 的 .png。

- (void) drawRect:(CGRect)area
{

[imgView.image drawInRect: area blendMode:blendMode alpha:alpha]; // draw image
}

blendMode 是正常的,alpha 是 1.0。图像很好,除了 alpha 是黑色的。任何帮助表示赞赏。

尝试了另一种绘图方法,但显示黑色 alpha 和上下颠倒(现在不在乎它是否上下颠倒)

- (void) drawRect:(CGRect)area
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);

// Draw picture first
CGContextDrawImage(context, area, imgView.image.CGImage);

CGContextRestoreGState(context);
}

【问题讨论】:

    标签: iphone iphone-sdk-3.0 image drawing drawrect


    【解决方案1】:
    [imagename drawInRect:CGRectMake(x, y, width, height)];
    

    [imagename drawAtPoint:CGPointMake(x, y)];
    

    【讨论】:

      【解决方案2】:

      我相信当您使用drawInRect:blendMode:alpha 时,您传入的 alpha 会覆盖图像中的 alpha。我刚才看的文档不是很清楚。

      【讨论】:

      • 如果没有drawInRect,我将如何绘制图像?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多