Пример #1
0
        public static byte[] CreateBitmapData(Emulation emulation, int width)
        {
            Bitmap sphereImage;

            using (var stream = Properties.Resources.sphere_image)
            {
                sphereImage = new Bitmap(stream);
            }

            Bitmap starLogoImage;

            using (var stream = Properties.Resources.star_logo_image)
            {
                starLogoImage = new Bitmap(stream);
            }

            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            builder.Append(Encoding.UTF8.GetBytes("*diffusion:true*\n"));
            builder.AppendBitmap(sphereImage, true);
            builder.Append(Encoding.UTF8.GetBytes("\n*diffusion:false*\n"));
            builder.AppendBitmap(sphereImage, false);

            builder.Append(Encoding.UTF8.GetBytes("\n*Normal*\n"));
            builder.AppendBitmap(starLogoImage, true);

            builder.Append(Encoding.UTF8.GetBytes("\n*width:Full, bothScale:true*\n"));
            builder.AppendBitmap(starLogoImage, true, width, true);
            builder.Append(Encoding.UTF8.GetBytes("\n*width:Full, bothScale:false*\n"));
            builder.AppendBitmap(starLogoImage, true, width, false);

            builder.Append(Encoding.UTF8.GetBytes("\n*Right90*\n"));
            builder.AppendBitmap(starLogoImage, true, BitmapConverterRotation.Right90);
            builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180*\n"));
            builder.AppendBitmap(starLogoImage, true, BitmapConverterRotation.Rotate180);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Left90*\n"));
            //builder.AppendBitmap(starLogoImage, true, BitmapConverterRotation.Left90);

            builder.Append(Encoding.UTF8.GetBytes("\n*Normal,    AbsolutePosition:40*\n"));
            builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, 40);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Right90,   AbsolutePosition:40*\n"));
            //builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, BitmapConverterRotation.Right90, 40);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180, AbsolutePosition:40*\n"));
            //builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, BitmapConverterRotation.Rotate180, 40);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Left90,    AbsolutePosition:40*\n"));
            //builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, BitmapConverterRotation.Left90, 40);

            builder.Append(Encoding.UTF8.GetBytes("\n*Normal,    Alignment:Center*\n"));
            builder.AppendBitmapWithAlignment(starLogoImage, true, AlignmentPosition.Center);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Right90,   Alignment:Center*\n"));
            //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Right90, AlignmentPosition.Center);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180, Alignment:Center*\n"));
            //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Rotate180, AlignmentPosition.Center);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Left90,    Alignment:Center*\n"));
            //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Left90, AlignmentPosition.Center);

            builder.Append(Encoding.UTF8.GetBytes("\n*Normal,    Alignment:Right*\n"));
            builder.AppendBitmapWithAlignment(starLogoImage, true, AlignmentPosition.Right);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Right90,   Alignment:Right*\n"));
            //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Right90, AlignmentPosition.Right);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180, Alignment:Right*\n"));
            //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Rotate180, AlignmentPosition.Right);
            //builder.Append(Encoding.UTF8.GetBytes("\n*Left90,    Alignment:Right*\n"));
            //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Left90, AlignmentPosition.Right);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }