示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            SaveFileDialog sfd = new SaveFileDialog();

            ofd.Multiselect = true;
            var oResult= ofd.ShowDialog();
            if (oResult==DialogResult.OK)
            {
                var files = ofd.FileNames;
                var temp1 = files.ToList();
                temp1.Sort();
                files = temp1.ToArray();

                Bitmap[] bitmaps = new Bitmap[files.Length];

                for (int i = 0; i < files.Length; i++)
                {
                    bitmaps[i] = new Bitmap(files[i]);
                }

                Bitmap output = new Bitmap(bitmaps[0].Width, bitmaps.Select(temp=>temp.Height).Sum());

                int yy = 0;

                for (int i = 0; i < bitmaps.Length; i++)
                {
                    for (int y = 0; y < bitmaps[i].Height; y++)
                    {
                        for (int x = 0; x < bitmaps[i].Width; x++)
                        {
                            var c = bitmaps[i].GetPixel(x, y);

                            output.SetPixel(x,yy, c);
                        }

                        yy++;
                    }
                }

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    output.Save(sfd.FileName, ImageFormat.Jpeg);
                }
            }

            sfd.Dispose();
            ofd.Dispose();
        }
示例#2
0
        public void Render(Bitmap[] images, float left, float top, float right, float bottom)
        {
            images = (images ?? new Bitmap[0]).Select(i => ((Bitmap)i.Clone()).ScaleTo(PrintBounds.Size)).ToArray();
            if (!images.Any()) return;

            var scanStart = Horizontal ? top : left;
            var scanEnd = Horizontal ? bottom : right;
            var lineStart = Horizontal ? left : top;
            var lineEnd = Horizontal ? right : bottom;

            var scanSize = Dpi/Lpi;
            var scanStep = scanSize/images.Length;
            var pens = images.Select(i => new Pen(new TextureBrush(i), scanStep)).ToArray();

            for (var position = scanStart; position < scanEnd; position += scanStep * pens.Length)
            for (var index = 0; index < pens.Length; index++) {
                var pen = pens[index];
                var offset = scanStep*index;
                RenderLine(_context.Graphics, pen, position + offset, lineStart, lineEnd);
            }

            pens.ToList().ForEach(p => p.Dispose());
            images.ToList().ForEach(i => i.Dispose());
        }
示例#3
0
 public void Load(Bitmap[] maps)
 {
     transform = BuildTransform(maps.Select(m => m.Size).ToArray());
     var bitmap = Merge(maps);
     this.parent.Resize(bitmap.Size);
     this.parent.LoadBitmap(bitmap);
 }