0

以下のようにReportViewerから画像バイト配列を作成しました

bytes=  reportViewer.ServerReport.Render("Image", null, out mimeType, out encoding, out extension, out streamids, out warnings);

そして、12ページの画像を作成する以下のコードを使用して物理パスに保存しました。

System.IO.File.WriteAllBytes(@"C:\test.jpeg", bytes);

<img>この画像をタグですべてのページに次々と表示したかったのです。

<img src="c://test.jpeg" />最初のページだけを表示する方法を試しました。

誰でもこれについて私を助けることができますか?

4

2 に答える 2

0

複数の写真を表示するには、html<img>タグを使用します。

ユニークな写真を表示するには、写真のラベルをimg1、img2、img3などに変更することをお勧めします。これにより、imgタグで次のようなことができるようになります。

<img src="folder/img<?php echo rand(1,10); ?>.jpg" />
于 2012-09-24T07:03:50.117 に答える
0

Find the answer below which i used to resolve this. Find the steps

First- Get all the frames from the stream of image as list of Images

public List<Image> GetAllFrames(Stream sm)
        {
            List<Image> images = new List<Image>();
            Bitmap bitmap = new Bitmap(sm);
            int count = bitmap.GetFrameCount(FrameDimension.Page);
            for (int idx = 0; idx < count; idx++)
            {
                bitmap.SelectActiveFrame(FrameDimension.Page, idx);
                MemoryStream byteStream = new MemoryStream();
                bitmap.Save(byteStream, ImageFormat.Tiff);

                images.Add(Image.FromStream(byteStream));
            }
            return images;
        }

Second - Combine all frames in to a single bitmap.

public Bitmap CombineAllFrames(List<Image> test)
        {
            int width = 0;
            int height = 0;
            Bitmap finalImage = null;
            try
            {
                foreach (Bitmap bitMap in test)
                {
                    height += bitMap.Height;
                    width = bitMap.Width > width ? bitMap.Width : width;
                }
                finalImage = new Bitmap(width, height);
                using (System.Drawing.Graphics gc = Graphics.FromImage(finalImage))
                {
                    gc.Clear(Color.White);
                    int offset = 0;
                    foreach (Bitmap bitmap in test)
                    {
                        gc.DrawImage(bitmap, new Rectangle(0, offset, bitmap.Width, bitmap.Height));
                        offset += bitmap.Width;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return finalImage;
        }

this methods creates a bitmap which will append all the frames into single one vertically. If you want it horizontally make update it to

    width += bitmap.Width;
           height = bitmap.Height > height ? bitmap.Height : height;
g.DrawImage(image, 
           new System.Drawing.Rectangle(offset, 0, image.Width, image.Height));

Third step - Now if you want a byte array for the created image call the below method.

public byte[] GetBytesFromImage(Bitmap finalImage)
        {
            ImageConverter convertor = new ImageConverter();
            return (byte[])convertor.ConvertTo(finalImage, typeof(byte[]));
        }

I think this will helps some one really needed. Please post if someone find a easy way to do it.

于 2012-09-24T11:55:07.260 に答える