Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将位图图像从自定义程序集返回到SSRS报告?_C#_Reporting Services_Bitmap - Fatal编程技术网

C# 如何将位图图像从自定义程序集返回到SSRS报告?

C# 如何将位图图像从自定义程序集返回到SSRS报告?,c#,reporting-services,bitmap,C#,Reporting Services,Bitmap,我正在使用QRCode4CS类()生成QR码 我可以使用以下代码成功地将位图图像返回到Windows窗体应用程序中的picturebox public class CreateQRCodeClass { public static Image CreateQRCodeImage(string inputString) { QRCode4CS.QRCode qrcode = new QRCode4CS.QRCode(new QRCode4CS.Options(inp

我正在使用QRCode4CS类()生成QR码

我可以使用以下代码成功地将位图图像返回到Windows窗体应用程序中的picturebox

public class CreateQRCodeClass
{
    public static Image CreateQRCodeImage(string inputString)
    {
        QRCode4CS.QRCode qrcode = new QRCode4CS.QRCode(new QRCode4CS.Options(inputString));
        qrcode.Make();
        Image canvas = new Bitmap(86, 86);
        Graphics artist = Graphics.FromImage(canvas);
        artist.Clear(Color.White);
        for (int row = 0; row < qrcode.GetModuleCount(); row++)
        {
            for (int col = 0; col < qrcode.GetModuleCount(); col++)
            {
                bool isDark = qrcode.IsDark(row, col);

                if (isDark == true)
                {
                    artist.FillRectangle(Brushes.Black, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
                else
                {
                    artist.FillRectangle(Brushes.White, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
            }
        }
        artist.FillRectangle(Brushes.White, 0, 76, 86, 86);
        artist.FillRectangle(Brushes.White, 76, 0, 86, 86);
        artist.Dispose();
        return canvas;
    }
}
这是修改后的自定义装配

public class CreateQRCodeClass
{
    public static byte[] CreateQRCodeImage(string inputString)
    {
        QRCode4CS.QRCode qrcode = new QRCode4CS.QRCode(new QRCode4CS.Options(inputString));
        qrcode.Make();
        Image canvas = new Bitmap(86, 86);
        Graphics artist = Graphics.FromImage(canvas);
        artist.Clear(Color.White);
        for (int row = 0; row < qrcode.GetModuleCount(); row++)
        {
            for (int col = 0; col < qrcode.GetModuleCount(); col++)
            {
                bool isDark = qrcode.IsDark(row, col);

                if (isDark == true)
                {
                    artist.FillRectangle(Brushes.Black, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
                else
                {
                    artist.FillRectangle(Brushes.White, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
            }
        }
        artist.FillRectangle(Brushes.White, 0, 76, 86, 86);
        artist.FillRectangle(Brushes.White, 76, 0, 86, 86);
        artist.Dispose();

        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        canvas.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        byte[] imagedata = null;
        imagedata = ms.GetBuffer();

        return imagedata;
    }
}
公共类CreateQRCodeClass
{
公共静态字节[]CreateQRCodeImage(字符串inputString)
{
QRCode4CS.QRCode QRCode=新的QRCode4CS.QRCode(新的QRCode4CS.Options(inputString));
qrcode.Make();
图像画布=新位图(86,86);
图形艺术家=Graphics.FromImage(画布);
艺术家。清晰(颜色。白色);
对于(int row=0;row

我可以成功返回到SSRS以显示图像的数据类型是什么?

我找到了答案

必须将位图图像转换为字节数组才能在SSRS中显示

这就是修订后的代码可以与SSR一起使用的样子

    public static Byte[] ReturnByteArray(string inputString)
    {
        QRCode4CS.QRCode qrcode = new QRCode4CS.QRCode(new QRCode4CS.Options(inputString));
        qrcode.Make();
        Image canvas = new Bitmap(86, 86);
        Graphics artist = Graphics.FromImage(canvas);
        artist.Clear(Color.White);
        for (int row = 0; row < qrcode.GetModuleCount(); row++)
        {
            for (int col = 0; col < qrcode.GetModuleCount(); col++)
            {
                bool isDark = qrcode.IsDark(row, col);

                if (isDark == true)
                {
                    artist.FillRectangle(Brushes.Black, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
                else
                {
                    artist.FillRectangle(Brushes.White, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
            }
        }
        artist.FillRectangle(Brushes.White, 0, 76, 86, 86);
        artist.FillRectangle(Brushes.White, 76, 0, 86, 86);
        artist.Dispose();

        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        canvas.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        byte[] imagedata = null;
        imagedata = ms.GetBuffer();

        return imagedata;
    }
公共静态字节[]ReturnByteArray(字符串inputString)
{
QRCode4CS.QRCode QRCode=新的QRCode4CS.QRCode(新的QRCode4CS.Options(inputString));
qrcode.Make();
图像画布=新位图(86,86);
图形艺术家=Graphics.FromImage(画布);
艺术家。清晰(颜色。白色);
对于(int row=0;row
您好,请问您是如何将DLL包含在rdl报告中的??
    public static Byte[] ReturnByteArray(string inputString)
    {
        QRCode4CS.QRCode qrcode = new QRCode4CS.QRCode(new QRCode4CS.Options(inputString));
        qrcode.Make();
        Image canvas = new Bitmap(86, 86);
        Graphics artist = Graphics.FromImage(canvas);
        artist.Clear(Color.White);
        for (int row = 0; row < qrcode.GetModuleCount(); row++)
        {
            for (int col = 0; col < qrcode.GetModuleCount(); col++)
            {
                bool isDark = qrcode.IsDark(row, col);

                if (isDark == true)
                {
                    artist.FillRectangle(Brushes.Black, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
                else
                {
                    artist.FillRectangle(Brushes.White, 2 * row + 10, 2 * col + 10, 2 * row + 15, 2 * col + 15);
                }
            }
        }
        artist.FillRectangle(Brushes.White, 0, 76, 86, 86);
        artist.FillRectangle(Brushes.White, 76, 0, 86, 86);
        artist.Dispose();

        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        canvas.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        byte[] imagedata = null;
        imagedata = ms.GetBuffer();

        return imagedata;
    }