Exemplo n.º 1
0
        /// <summary>Makes kindle cover.</summary>
        /// <param name="rhombusTiler">The rhombus tiler.</param>
        /// <param name="sizeBookTrimInches">The size book trim inches.</param>
        private static void MakeKindleCover(RhombusTiler rhombusTiler, SizeF sizeBookTrimInches)
        {
            Contract.Requires <ArgumentNullException>(rhombusTiler != null);

            int   kindleHeight      = Settings.Default.KindleHeight;
            float kindleAspectRatio = Settings.Default.KindleAspectRatio;
            Size  sizeCoverKindle   = new Size((int)(kindleHeight / kindleAspectRatio), kindleHeight);
            int   dpiKindle         = (int)(kindleHeight / sizeBookTrimInches.Height);

            // Get the background image
            using (Bitmap bitmap = rhombusTiler.GetBitmap(sizeCoverKindle, dpiKindle))
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    float      marginSafe    = Settings.Default.MarginSafeInches * dpiKindle;
                    RectangleF rectSafeFront = new RectangleF(
                        marginSafe,
                        marginSafe,
                        bitmap.Width - (marginSafe * 2),
                        bitmap.Height - (marginSafe * 2));

                    Program.AddFrontCoverText(graphics, dpiKindle, rectSafeFront);
                }

                dpiKindle = Settings.Default.KindleDpi;
                bitmap.SetResolution(dpiKindle, dpiKindle);

                string fileNameKindle = Path.Combine(Path.GetTempPath(), FileNameKindle);
                bitmap.Save(fileNameKindle, ImageFormat.Tiff);

                // View the tif
                Process.Start(fileNameKindle);
            }
        }
Exemplo n.º 2
0
        /// <summary>Makes create space cover.</summary>
        /// <param name="rhombusTiler">The rhombus tiler.</param>
        /// <param name="sizeBookTrimInches">The size book trim inches.</param>
        private static void MakeCreateSpaceCover(RhombusTiler rhombusTiler, SizeF sizeBookTrimInches)
        {
            Contract.Requires <ArgumentNullException>(rhombusTiler != null);

            int   dpi            = Settings.Default.CreateSpaceDpi;
            float marginBleed    = Settings.Default.MarginBleedInches * dpi;
            SizeF sizeBookTrim   = new SizeF(sizeBookTrimInches.Width * dpi, sizeBookTrimInches.Height * dpi);
            float spineThickness = Program.PageThicknessInches * Settings.Default.BookPageCount * dpi;

            Size sizeCover = new Size(
                (int)(((sizeBookTrim.Width + marginBleed) * 2) + spineThickness),
                (int)(sizeBookTrim.Height + (marginBleed * 2)));

            // Get the background image
            using (Bitmap bitmap = rhombusTiler.GetBitmap(sizeCover, dpi))
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    // Add the elements to the image
                    Program.AddTextAndImages(
                        graphics,
                        bitmap.Size,
                        dpi,
                        sizeBookTrim,
                        spineThickness,
                        marginBleed);
                }

                // Create the pdf
                string fileName = Program.CreateSpacePdf(bitmap);

                // View the pdf
                Process.Start(fileName);
            }
        }
Exemplo n.º 3
0
		/// <summary>Makes kindle cover.</summary>
		/// <param name="rhombusTiler">The rhombus tiler.</param>
		/// <param name="sizeBookTrimInches">The size book trim inches.</param>
		private static void MakeKindleCover(RhombusTiler rhombusTiler, SizeF sizeBookTrimInches)
		{
			Contract.Requires<ArgumentNullException>(rhombusTiler != null);

			int kindleHeight = Settings.Default.KindleHeight;
			float kindleAspectRatio = Settings.Default.KindleAspectRatio;
			Size sizeCoverKindle = new Size((int)(kindleHeight / kindleAspectRatio), kindleHeight);
			int dpiKindle = (int)(kindleHeight / sizeBookTrimInches.Height);

			// Get the background image
			using (Bitmap bitmap = rhombusTiler.GetBitmap(sizeCoverKindle, dpiKindle))
			{
				using (Graphics graphics = Graphics.FromImage(bitmap))
				{
					float marginSafe = Settings.Default.MarginSafeInches * dpiKindle;
					RectangleF rectSafeFront = new RectangleF(
						marginSafe,
						marginSafe,
						bitmap.Width - (marginSafe * 2),
						bitmap.Height - (marginSafe * 2));

					Program.AddFrontCoverText(graphics, dpiKindle, rectSafeFront);
				}

				dpiKindle = Settings.Default.KindleDpi;
				bitmap.SetResolution(dpiKindle, dpiKindle);

				string fileNameKindle = Path.Combine(Path.GetTempPath(), FileNameKindle);
				bitmap.Save(fileNameKindle, ImageFormat.Tiff);

				// View the tif
				Process.Start(fileNameKindle);
			}
		}
Exemplo n.º 4
0
		/// <summary>Makes create space cover.</summary>
		/// <param name="rhombusTiler">The rhombus tiler.</param>
		/// <param name="sizeBookTrimInches">The size book trim inches.</param>
		private static void MakeCreateSpaceCover(RhombusTiler rhombusTiler, SizeF sizeBookTrimInches)
		{
			Contract.Requires<ArgumentNullException>(rhombusTiler != null);

			int dpi = Settings.Default.CreateSpaceDpi;
			float marginBleed = Settings.Default.MarginBleedInches * dpi;
			SizeF sizeBookTrim = new SizeF(sizeBookTrimInches.Width * dpi, sizeBookTrimInches.Height * dpi);
			float spineThickness = Program.PageThicknessInches * Settings.Default.BookPageCount * dpi;

			Size sizeCover = new Size(
				(int)(((sizeBookTrim.Width + marginBleed) * 2) + spineThickness),
				(int)(sizeBookTrim.Height + (marginBleed * 2)));

			// Get the background image
			using (Bitmap bitmap = rhombusTiler.GetBitmap(sizeCover, dpi))
			{
				using (Graphics graphics = Graphics.FromImage(bitmap))
				{
					// Add the elements to the image
					Program.AddTextAndImages(
						graphics,
						bitmap.Size,
						dpi,
						sizeBookTrim,
						spineThickness,
						marginBleed);
				}

				// Create the pdf
				string fileName = Program.CreateSpacePdf(bitmap);

				// View the pdf
				Process.Start(fileName);
			}
		}