I am using the QRCode4CS class ([url=http://qrcode4cs.codeplex.com/releases/view/74015]http://qrcode4cs.codeplex.com/releases/view/74015[/url]) to generate QR codes.I can use the following code to successfully return a bitmap image to a picturebox in a Windows Form Application.[code="other"] 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; } }[/code]In trying to adapt the same code (below) to display a QR code in an SSRS report I get the error "There is an error on line 1 of custom code: [BC30311] Value of type 'System.Drawing.Image' cannot be converted to '1-dimensional array of Byte.'Here is the custom code I am using.[code="vb"] Public Function QRCode(ByVal RetailerId As String) as Byte() Return QRCode4CSCreateQRCode.CreateQRCodeClass.CreateQRCodeImage(RetailerId) End Function[/code]Here is the revised custom assembly.[code="other"] 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; } }[/code]What data type can I successfully return to SSRS to display the image?
↧