`图形'是一个模糊的参考`UnityEngine.Graphics'和`System.Drawing.Graphics'

时间:2015-05-05 06:08:11

标签: c# graphics unity3d

我正在进行一个团结项目,我已经制作了一个c#脚本来改变图像的亮度。

由于统一不支持使用System.Drawing,我为此导入了System.Drawing.dll文件。

所以我能够使用它。

以下是我的代码。

using UnityEngine;
using System.Collections;
using System;
using System.Drawing;
using System.Drawing.Imaging;


public class NewBehaviourScript : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () 
    {
        Bitmap originalImage;
        Bitmap adjustedImage;
        float brightness = 1.0f; // no change in brightness
        float contrast = 2.0f; // twice the contrast
        float gamma = 1.0f; // no change in gamma

        float adjustedBrightness = brightness - 1.0f;
        // create matrix that will brighten and contrast the image
        float[][] ptsArray ={
            new float[] {contrast, 0, 0, 0, 0} , // scale red
            new float[] {0, contrast, 0, 0, 0} , // scale green
            new float[] {0, 0, contrast, 0, 0} , // scale blue
            new float[] {0, 0, 0, 1.0f, 0} , // don't scale alpha
            new float[] {adjustedBrightness, adjustedBrightness, adjustedBrightness, 0, 1}} ;

        ImageAttributes imageAttributes = new ImageAttributes();
        imageAttributes.ClearColorMatrix();
        imageAttributes.SetColorMatrix(new ColorMatrix(ptsArray), ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
        imageAttributes.SetGamma(gamma, ColorAdjustType.Bitmap);


        Graphics g = Graphics.FromImage(adjustedImage);
        g.DrawImage(originalImage, new Rectangle(0,0,adjustedImage.Width,adjustedImage.Height)
                    ,0,0,originalImage.Width,originalImage.Height,
                    GraphicsUnit.Pixel, imageAttributes);
    }
}

由于上述错误,我尝试解决using this,但它仍然无法解决我的问题。

我怎么能解决这个问题?

1 个答案:

答案 0 :(得分:3)

为什么不使用完全限定名称(包括namespace),例如

System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(...