diff --git a/TBO/ImageWorks.cs b/TBO/ImageWorks.cs
new file mode 100644
index 0000000..b366374
--- /dev/null
+++ b/TBO/ImageWorks.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+namespace TBO
+{
+ static class ImageWorks
+ {
+ public static Bitmap To8bppGraysacle(Image i)
+ {
+ Bitmap bmp = new Bitmap(i.Width, i.Height, PixelFormat.Format8bppIndexed);
+ ColorPalette pal = bmp.Palette;
+ for (int p = 0; p <= 255; p++)
+ pal.Entries[p] = Color.FromArgb(p, p, p);
+ bmp.Palette = pal;
+ return null;
+ }
+
+ public static bool IsGray(Image i)
+ {
+ byte[] rgb;
+ using (Bitmap bmp = new Bitmap(i))
+ {
+ BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
+ rgb = new byte[Math.Abs(bd.Stride) * bmp.Height];
+ System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, rgb, 0, rgb.Length);
+ bmp.UnlockBits(bd);
+ }
+ for (int x = 0; x < rgb.Length; x += 3)
+ if (rgb[x] - rgb[x + 1] > 10 || rgb[x] - rgb[x + 2] > 10)
+ return false;
+ return true;
+ }
+
+ public static Bitmap ToBpp(Image i, PixelFormat toBPP)
+ {
+ Bitmap bmpto;
+ using (Bitmap bmp = new Bitmap(i))
+ {
+ bmpto = new Bitmap(bmp.Width, bmp.Height, toBPP);
+ BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, toBPP);
+ BitmapData bdto = bmpto.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, toBPP);
+
+ byte[] pixels = new byte[Math.Abs(bd.Stride) * bmp.Height];
+
+ // Copy the RGB values into the array.
+ System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, pixels, 0, pixels.Length);
+
+ // Copy the RGB values back to the bitmap
+ System.Runtime.InteropServices.Marshal.Copy(pixels, 0, bdto.Scan0, pixels.Length);
+
+ bmp.UnlockBits(bd);
+ bmpto.UnlockBits(bdto);
+ }
+ return bmpto;
+ }
+
+ public static Bitmap ToBppGray(Image i, PixelFormat toBPP)
+ {
+ Bitmap bmpto;
+ using (Bitmap bmp = new Bitmap(i))
+ {
+ bmpto = new Bitmap(bmp.Width, bmp.Height, toBPP);
+
+ ColorPalette pal = bmpto.Palette;
+ for (int x = 0; x < pal.Entries.Length; x++)
+ {
+ int l = (x * 255) / (pal.Entries.Length - 1);
+ pal.Entries[x] = Color.FromArgb(l, l, l);
+ }
+ bmp.Palette = pal;
+ bmpto.Palette = pal;
+
+ BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, toBPP);
+ BitmapData bdto = bmpto.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, toBPP);
+
+ byte[] pixels = new byte[Math.Abs(bd.Stride) * bmp.Height];
+
+ // Copy the RGB values into the array.
+ System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, pixels, 0, pixels.Length);
+
+ // Copy the RGB values back to the bitmap
+ System.Runtime.InteropServices.Marshal.Copy(pixels, 0, bdto.Scan0, pixels.Length);
+
+ bmp.UnlockBits(bd);
+ bmpto.UnlockBits(bdto);
+ }
+ return bmpto;
+ }
+
+ public static Bitmap ToBppGray(Image i, PixelFormat toBPP, int[] palette)
+ {
+ Bitmap bmpto;
+ using (Bitmap bmp = new Bitmap(i))
+ {
+ bmpto = new Bitmap(bmp.Width, bmp.Height, toBPP);
+
+ ColorPalette pal = bmpto.Palette;
+ for (int x = 0; x < pal.Entries.Length; x++)
+ {
+ int l = x < palette.Length ? palette[x] : palette[palette.Length - 1];
+ pal.Entries[x] = Color.FromArgb(l, l, l);
+ }
+ bmp.Palette = pal;
+ bmpto.Palette = pal;
+
+ BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, toBPP);
+ BitmapData bdto = bmpto.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, toBPP);
+
+ byte[] pixels = new byte[Math.Abs(bd.Stride) * bmp.Height];
+
+ // Copy the RGB values into the array.
+ System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, pixels, 0, pixels.Length);
+
+ // Copy the RGB values back to the bitmap
+ System.Runtime.InteropServices.Marshal.Copy(pixels, 0, bdto.Scan0, pixels.Length);
+
+ bmp.UnlockBits(bd);
+ bmpto.UnlockBits(bdto);
+ }
+ return bmpto;
+ }
+
+
+ }
+}
diff --git a/TBO/TBO.csproj b/TBO/TBO.csproj
index 25acdb8..fc27e01 100644
--- a/TBO/TBO.csproj
+++ b/TBO/TBO.csproj
@@ -47,6 +47,7 @@
+
@@ -89,6 +90,7 @@
Studio.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/TBO/TBOFile.cs b/TBO/TBOFile.cs
index 03bbcd2..2fb2320 100644
--- a/TBO/TBOFile.cs
+++ b/TBO/TBOFile.cs
@@ -1,11 +1,313 @@
using System;
using System.Collections.Generic;
-using System.Linq;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
using System.Text;
namespace TBO
{
- class TBOFile
+ class TBOFile : IDisposable
{
+ private const string FILEHEADER = "TBO";
+ private const int EOF = 0x1A;
+ private const int FILEVERSION = 0;
+
+ private static ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);
+ private static EncoderParameters eParams = new EncoderParameters(1);
+
+ private FileStream fs;
+ private bool readOnly;
+ private bool empty;
+ private long metapos;
+ private long[] pagepos;
+
+ static TBOFile()
+ {
+ eParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60L);
+ }
+
+ public TBOFile(string filePath)
+ {
+ try
+ {
+ fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
+ }
+ catch
+ {
+ try
+ {
+ fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
+ readOnly = true;
+ }
+ catch { throw new Exception("No se pudo abrir ni crear el archivo"); }
+ }
+ if (fs.Length == 0)
+ WriteHeader();
+ else
+ ReadHeader();
+ ReadDirectory();
+ ReadMetadata();
+ }
+
+ private static ImageCodecInfo GetEncoder(ImageFormat format)
+ {
+ ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
+ foreach (ImageCodecInfo codec in codecs)
+ {
+ if (codec.FormatID == format.Guid)
+ {
+ return codec;
+ }
+ }
+ return null;
+ }
+
+ public void Dispose()
+ {
+ fs.Close();
+ }
+
+ private void ReadDirectory()
+ {
+ List poses = new List();
+ long pos = fs.Position;
+ int lng;
+ while ((lng = ReadInt()) > 0)
+ {
+ poses.Add(pos);
+ fs.Position = pos = fs.Position + lng;
+ }
+ pagepos = poses.ToArray();
+ }
+
+ private void ReadMetadata()
+ {
+ metapos = fs.Position;
+ if (fs.Position >= fs.Length)
+ return;
+ string metaJSON = ReadString();
+ }
+
+ #region I/O
+
+ private void ReadHeader()
+ {
+ empty = false;
+ fs.Position = 0;
+ if (Encoding.ASCII.GetString(Read(FILEHEADER.Length)) != FILEHEADER)
+ throw new Exception("El arhivo no es un tebeo");
+ if (fs.ReadByte() != EOF)
+ throw new Exception("Error al leer el tebeo");
+ if (fs.ReadByte() != FILEVERSION)
+ throw new Exception("No se puede leer esta versión del tebeo");
+ }
+
+ private void WriteHeader()
+ {
+ empty = true;
+ fs.Position = 0;
+ Write(Encoding.ASCII.GetBytes(FILEHEADER));
+ fs.WriteByte(EOF);
+ fs.WriteByte(FILEVERSION);
+ }
+
+ private void Write(byte[] buf)
+ {
+ fs.Write(buf, 0, buf.Length);
+ }
+
+ private byte[] Read(int len)
+ {
+ byte[] buf = new byte[len];
+ fs.Read(buf, 0, len);
+ return buf;
+ }
+
+ private void WriteInt(int i)
+ {
+ Write(BitConverter.GetBytes(i));
+ }
+
+ private int ReadInt()
+ {
+ byte[] buf = Read(sizeof(int));
+ return BitConverter.ToInt32(buf, 0);
+ }
+
+ private void WriteBlock(byte[] buf)
+ {
+ if (buf == null)
+ WriteInt(0);
+ else
+ {
+ WriteInt(buf.Length);
+ Write(buf);
+ }
+ }
+
+ private byte[] ReadBlock()
+ {
+ int lng = ReadInt();
+ if (lng == 0)
+ return null;
+ return Read(lng);
+ }
+
+ private void WriteString(string data)
+ {
+ if (data == null)
+ data = string.Empty;
+ WriteBlock(Encoding.UTF8.GetBytes(data));
+ }
+
+ private string ReadString()
+ {
+ return Encoding.UTF8.GetString(ReadBlock());
+ }
+
+ private Image ReadImage()
+ {
+ MemoryStream ms = new MemoryStream(ReadBlock());
+ return Image.FromStream(ms);
+ }
+
+ private void WriteImage(Image i)
+ {
+ WriteBlock(ImageJPEG(i));
+ }
+
+ #endregion
+
+ public void AppendImage(string filename,int num)
+ {
+ byte[] image;
+ FileInfo fi = new FileInfo(filename);
+ using (Image i = Image.FromFile(filename))
+ {
+ image = GetImageBytes(i);
+ if (image.Length > fi.Length)
+ image = File.ReadAllBytes(filename);
+ }
+ WriteBlock(image);
+ //Test
+ File.WriteAllBytes("C:\\Users\\XWolf\\Desktop\\out\\" + num+".jpg",image);
+ }
+
+ private byte[] GetImageBytes(Image i)
+ {
+ byte[] img = ImageJPEG(i);
+ if (Grayscale == 0)
+ return img;
+ if (KeepColors && !ImageWorks.IsGray(i))
+ return img;
+ byte[] gimg;
+ switch (Grayscale)
+ {
+ case 256:
+ gimg = ImagePNG8bpp(i);
+ break;
+ case 16:
+ gimg = ImagePNG4bpp(i);
+ break;
+ case 8:
+ gimg = ImagePNG4bpp(i, new int[] { 0, 37, 73, 110, 146, 183, 219, 255 });
+ break;
+ case 6:
+ gimg = ImagePNG4bpp(i, new int[] { 0, 51, 102, 154, 204, 255 });
+ break;
+ case 4:
+ gimg = ImagePNG4bpp(i, new int[] { 0, 85, 170, 255 });
+ break;
+ case 2:
+ gimg = ImagePNG1bpp(i);
+ break;
+ default:
+ throw new Exception("Only 256,16,8,6,4,2 and 0 values are valid.");
+ }
+ return gimg.Length < img.Length ? gimg : img;
+ }
+
+ public void TestImage(string filename)
+ {
+ string namebase = Path.Combine(Path.GetDirectoryName(fs.Name), Path.GetFileNameWithoutExtension(fs.Name));
+ using (Image i = Image.FromFile(filename))
+ {
+ File.WriteAllBytes(namebase + ".jpeg", ImageJPEG(i));
+ File.WriteAllBytes(namebase + ".8.png", ImagePNG8bpp(i));
+ File.WriteAllBytes(namebase + ".4.png", ImagePNG4bpp(i));
+ }
+ }
+
+ private byte[] ImageJPEG(Image i)
+ {
+ if (i == null)
+ return null;
+ MemoryStream ms = new MemoryStream();
+ i.Save(ms, jpgEncoder, eParams);
+ return ms.ToArray();
+ }
+
+ private byte[] ImagePNG(Image i)
+ {
+ if (i == null)
+ return null;
+ MemoryStream ms = new MemoryStream();
+ i.Save(ms, ImageFormat.Png);
+ return ms.ToArray();
+ }
+
+ private byte[] ImageGIF(Image i)
+ {
+ if (i == null)
+ return null;
+ MemoryStream ms = new MemoryStream();
+ i.Save(ms, ImageFormat.Gif);
+ return ms.ToArray();
+ }
+
+ private byte[] ImagePNG8bpp(Image i)
+ {
+ if (i == null)
+ return null;
+ using (Bitmap bmp = ImageWorks.ToBppGray(i, PixelFormat.Format8bppIndexed))
+ return ImagePNG(bmp);
+ }
+
+ private byte[] ImagePNG4bpp(Image i)
+ {
+ if (i == null)
+ return null;
+ using (Bitmap bmp = ImageWorks.ToBppGray(i, PixelFormat.Format4bppIndexed))
+ return ImagePNG(bmp);
+ }
+
+ private byte[] ImagePNG4bpp(Image i, int[] palette)
+ {
+ if (i == null)
+ return null;
+ using (Bitmap bmp = ImageWorks.ToBppGray(i, PixelFormat.Format4bppIndexed, palette))
+ return ImagePNG(bmp);
+ }
+
+ private byte[] ImagePNG1bpp(Image i)
+ {
+ if (i == null)
+ return null;
+ using (Bitmap bmp = ImageWorks.ToBpp(i, PixelFormat.Format1bppIndexed))
+ return ImagePNG(bmp);
+ }
+
+ public string Title { get; set; }
+ public string Variant { get; set; }
+ public string Volume { get; set; }
+ public string Author { get; set; }
+ public string Publisher { get; set; }
+ public int Year { get; set; }
+ public string Comments { get; set; }
+ public int Grayscale { get; set; } = 16;
+ public bool KeepColors { get; set; } = true;
+
+ public long Size => fs.Length;
}
}
diff --git a/TBO/UI/Windows/Studio.Designer.cs b/TBO/UI/Windows/Studio.Designer.cs
index 6a6bccd..fc247f0 100644
--- a/TBO/UI/Windows/Studio.Designer.cs
+++ b/TBO/UI/Windows/Studio.Designer.cs
@@ -37,6 +37,28 @@
this.btTBO = new System.Windows.Forms.Button();
this.tbTBO = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
+ this.pbGo = new System.Windows.Forms.ProgressBar();
+ this.btGo = new System.Windows.Forms.Button();
+ this.lbInfo = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.tbTitle = new System.Windows.Forms.TextBox();
+ this.label6 = new System.Windows.Forms.Label();
+ this.tbAuthor = new System.Windows.Forms.TextBox();
+ this.tbPublisher = new System.Windows.Forms.TextBox();
+ this.label7 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.nudYear = new System.Windows.Forms.NumericUpDown();
+ this.label9 = new System.Windows.Forms.Label();
+ this.tbCom = new System.Windows.Forms.TextBox();
+ this.tbVolume = new System.Windows.Forms.TextBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.tbVar = new System.Windows.Forms.TextBox();
+ this.label11 = new System.Windows.Forms.Label();
+ this.cbGrayscale = new System.Windows.Forms.CheckBox();
+ this.cbDepth = new System.Windows.Forms.ComboBox();
+ this.label12 = new System.Windows.Forms.Label();
+ this.cbColor = new System.Windows.Forms.CheckBox();
+ ((System.ComponentModel.ISupportInitialize)(this.nudYear)).BeginInit();
this.SuspendLayout();
//
// label1
@@ -56,7 +78,7 @@
this.label2.BackColor = System.Drawing.Color.LightYellow;
this.label2.Location = new System.Drawing.Point(23, 25);
this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(307, 60);
+ this.label2.Size = new System.Drawing.Size(362, 76);
this.label2.TabIndex = 1;
this.label2.Text = resources.GetString("label2.Text");
//
@@ -64,67 +86,304 @@
//
this.tbInputDir.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.tbInputDir.Location = new System.Drawing.Point(12, 88);
+ this.tbInputDir.Location = new System.Drawing.Point(12, 104);
this.tbInputDir.Name = "tbInputDir";
- this.tbInputDir.Size = new System.Drawing.Size(287, 20);
- this.tbInputDir.TabIndex = 2;
+ this.tbInputDir.Size = new System.Drawing.Size(342, 20);
+ this.tbInputDir.TabIndex = 0;
//
// btInputDir
//
this.btInputDir.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btInputDir.Location = new System.Drawing.Point(305, 88);
+ this.btInputDir.Location = new System.Drawing.Point(360, 104);
this.btInputDir.Name = "btInputDir";
this.btInputDir.Size = new System.Drawing.Size(25, 20);
- this.btInputDir.TabIndex = 3;
+ this.btInputDir.TabIndex = 1;
this.btInputDir.Text = "...";
this.btInputDir.UseVisualStyleBackColor = true;
+ this.btInputDir.Click += new System.EventHandler(this.btInputDir_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label3.Location = new System.Drawing.Point(12, 123);
+ this.label3.Location = new System.Drawing.Point(12, 139);
this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(83, 13);
+ this.label3.Size = new System.Drawing.Size(76, 13);
this.label3.TabIndex = 4;
- this.label3.Text = "Archivo TBO:";
+ this.label3.Text = "Archivo tbo:";
//
// btTBO
//
this.btTBO.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btTBO.Location = new System.Drawing.Point(305, 171);
+ this.btTBO.Location = new System.Drawing.Point(360, 179);
this.btTBO.Name = "btTBO";
this.btTBO.Size = new System.Drawing.Size(25, 20);
- this.btTBO.TabIndex = 7;
+ this.btTBO.TabIndex = 3;
this.btTBO.Text = "...";
this.btTBO.UseVisualStyleBackColor = true;
+ this.btTBO.Click += new System.EventHandler(this.btTBO_Click);
//
// tbTBO
//
this.tbTBO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.tbTBO.Location = new System.Drawing.Point(12, 171);
+ this.tbTBO.Location = new System.Drawing.Point(12, 179);
this.tbTBO.Name = "tbTBO";
- this.tbTBO.Size = new System.Drawing.Size(287, 20);
- this.tbTBO.TabIndex = 6;
+ this.tbTBO.Size = new System.Drawing.Size(342, 20);
+ this.tbTBO.TabIndex = 2;
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label4.BackColor = System.Drawing.Color.LightYellow;
- this.label4.Location = new System.Drawing.Point(23, 136);
+ this.label4.Location = new System.Drawing.Point(23, 152);
this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(307, 32);
+ this.label4.Size = new System.Drawing.Size(362, 24);
this.label4.TabIndex = 5;
- this.label4.Text = "Archivo con el resultado de la unión de todas las imágenes en el TBO.";
+ this.label4.Text = "Archivo con el resultado de la unión de todas las imágenes en el tebeo.";
+ //
+ // pbGo
+ //
+ this.pbGo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pbGo.Location = new System.Drawing.Point(12, 410);
+ this.pbGo.Name = "pbGo";
+ this.pbGo.Size = new System.Drawing.Size(292, 23);
+ this.pbGo.TabIndex = 8;
+ //
+ // btGo
+ //
+ this.btGo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.btGo.Location = new System.Drawing.Point(310, 410);
+ this.btGo.Name = "btGo";
+ this.btGo.Size = new System.Drawing.Size(75, 23);
+ this.btGo.TabIndex = 14;
+ this.btGo.Text = "Go!";
+ this.btGo.UseVisualStyleBackColor = true;
+ this.btGo.Click += new System.EventHandler(this.btGo_Click);
+ //
+ // lbInfo
+ //
+ this.lbInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.lbInfo.AutoSize = true;
+ this.lbInfo.Location = new System.Drawing.Point(12, 394);
+ this.lbInfo.Name = "lbInfo";
+ this.lbInfo.Size = new System.Drawing.Size(16, 13);
+ this.lbInfo.TabIndex = 10;
+ this.lbInfo.Text = " ";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(17, 219);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(38, 13);
+ this.label5.TabIndex = 11;
+ this.label5.Text = "Título:";
+ //
+ // tbTitle
+ //
+ this.tbTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbTitle.Location = new System.Drawing.Point(61, 216);
+ this.tbTitle.Name = "tbTitle";
+ this.tbTitle.Size = new System.Drawing.Size(324, 20);
+ this.tbTitle.TabIndex = 4;
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(17, 271);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(35, 13);
+ this.label6.TabIndex = 14;
+ this.label6.Text = "Autor:";
+ //
+ // tbAuthor
+ //
+ this.tbAuthor.Location = new System.Drawing.Point(70, 268);
+ this.tbAuthor.Name = "tbAuthor";
+ this.tbAuthor.Size = new System.Drawing.Size(83, 20);
+ this.tbAuthor.TabIndex = 7;
+ //
+ // tbPublisher
+ //
+ this.tbPublisher.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbPublisher.Location = new System.Drawing.Point(212, 268);
+ this.tbPublisher.Name = "tbPublisher";
+ this.tbPublisher.Size = new System.Drawing.Size(81, 20);
+ this.tbPublisher.TabIndex = 8;
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Location = new System.Drawing.Point(159, 271);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(47, 13);
+ this.label7.TabIndex = 17;
+ this.label7.Text = "Editorial:";
+ //
+ // label8
+ //
+ this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(299, 271);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(29, 13);
+ this.label8.TabIndex = 18;
+ this.label8.Text = "Año:";
+ //
+ // nudYear
+ //
+ this.nudYear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.nudYear.Location = new System.Drawing.Point(331, 268);
+ this.nudYear.Maximum = new decimal(new int[] {
+ 5000,
+ 0,
+ 0,
+ 0});
+ this.nudYear.Name = "nudYear";
+ this.nudYear.Size = new System.Drawing.Size(54, 20);
+ this.nudYear.TabIndex = 9;
+ this.nudYear.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.nudYear.Value = new decimal(new int[] {
+ 1985,
+ 0,
+ 0,
+ 0});
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Location = new System.Drawing.Point(17, 291);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(63, 13);
+ this.label9.TabIndex = 20;
+ this.label9.Text = "Comentario:";
+ //
+ // tbCom
+ //
+ this.tbCom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbCom.Location = new System.Drawing.Point(86, 294);
+ this.tbCom.Multiline = true;
+ this.tbCom.Name = "tbCom";
+ this.tbCom.Size = new System.Drawing.Size(299, 55);
+ this.tbCom.TabIndex = 10;
+ //
+ // tbVolume
+ //
+ this.tbVolume.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbVolume.Location = new System.Drawing.Point(261, 242);
+ this.tbVolume.Name = "tbVolume";
+ this.tbVolume.Size = new System.Drawing.Size(124, 20);
+ this.tbVolume.TabIndex = 6;
+ //
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Location = new System.Drawing.Point(204, 245);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(51, 13);
+ this.label10.TabIndex = 22;
+ this.label10.Text = "Volumen:";
+ //
+ // tbVar
+ //
+ this.tbVar.Location = new System.Drawing.Point(70, 242);
+ this.tbVar.Name = "tbVar";
+ this.tbVar.Size = new System.Drawing.Size(128, 20);
+ this.tbVar.TabIndex = 5;
+ //
+ // label11
+ //
+ this.label11.AutoSize = true;
+ this.label11.Location = new System.Drawing.Point(15, 245);
+ this.label11.Name = "label11";
+ this.label11.Size = new System.Drawing.Size(49, 13);
+ this.label11.TabIndex = 24;
+ this.label11.Text = "Variante:";
+ //
+ // cbGrayscale
+ //
+ this.cbGrayscale.AutoSize = true;
+ this.cbGrayscale.Checked = true;
+ this.cbGrayscale.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.cbGrayscale.Location = new System.Drawing.Point(15, 364);
+ this.cbGrayscale.Name = "cbGrayscale";
+ this.cbGrayscale.Size = new System.Drawing.Size(48, 17);
+ this.cbGrayscale.TabIndex = 11;
+ this.cbGrayscale.Text = "Usar";
+ this.cbGrayscale.UseVisualStyleBackColor = true;
+ //
+ // cbDepth
+ //
+ this.cbDepth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbDepth.FormattingEnabled = true;
+ this.cbDepth.ItemHeight = 13;
+ this.cbDepth.Items.AddRange(new object[] {
+ "256",
+ "16",
+ "8",
+ "6",
+ "4",
+ "2"});
+ this.cbDepth.Location = new System.Drawing.Point(61, 362);
+ this.cbDepth.Name = "cbDepth";
+ this.cbDepth.Size = new System.Drawing.Size(60, 21);
+ this.cbDepth.TabIndex = 12;
+ //
+ // label12
+ //
+ this.label12.AutoSize = true;
+ this.label12.Location = new System.Drawing.Point(123, 365);
+ this.label12.Name = "label12";
+ this.label12.Size = new System.Drawing.Size(114, 13);
+ this.label12.TabIndex = 27;
+ this.label12.Text = "grises para las páginas";
+ //
+ // cbColor
+ //
+ this.cbColor.AutoSize = true;
+ this.cbColor.Checked = true;
+ this.cbColor.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.cbColor.Location = new System.Drawing.Point(243, 364);
+ this.cbColor.Name = "cbColor";
+ this.cbColor.Size = new System.Drawing.Size(125, 17);
+ this.cbColor.TabIndex = 13;
+ this.cbColor.Text = "Excepto las de color.";
+ this.cbColor.UseVisualStyleBackColor = true;
//
// Studio
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
- this.ClientSize = new System.Drawing.Size(342, 452);
+ this.ClientSize = new System.Drawing.Size(397, 445);
+ this.Controls.Add(this.cbColor);
+ this.Controls.Add(this.label12);
+ this.Controls.Add(this.cbDepth);
+ this.Controls.Add(this.cbGrayscale);
+ this.Controls.Add(this.tbVar);
+ this.Controls.Add(this.label11);
+ this.Controls.Add(this.tbVolume);
+ this.Controls.Add(this.label10);
+ this.Controls.Add(this.tbCom);
+ this.Controls.Add(this.label9);
+ this.Controls.Add(this.nudYear);
+ this.Controls.Add(this.label8);
+ this.Controls.Add(this.label7);
+ this.Controls.Add(this.tbPublisher);
+ this.Controls.Add(this.tbAuthor);
+ this.Controls.Add(this.label6);
+ this.Controls.Add(this.tbTitle);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.lbInfo);
+ this.Controls.Add(this.btGo);
+ this.Controls.Add(this.pbGo);
this.Controls.Add(this.btTBO);
this.Controls.Add(this.tbTBO);
this.Controls.Add(this.label4);
@@ -134,10 +393,14 @@
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.DoubleBuffered = true;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.MaximizeBox = false;
this.Name = "Studio";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "TBO: Studio";
+ this.Load += new System.EventHandler(this.Studio_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.nudYear)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -153,5 +416,26 @@
private System.Windows.Forms.Button btTBO;
private System.Windows.Forms.TextBox tbTBO;
private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.ProgressBar pbGo;
+ private System.Windows.Forms.Button btGo;
+ private System.Windows.Forms.Label lbInfo;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.TextBox tbTitle;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.TextBox tbAuthor;
+ private System.Windows.Forms.TextBox tbPublisher;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.NumericUpDown nudYear;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.TextBox tbCom;
+ private System.Windows.Forms.TextBox tbVolume;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.TextBox tbVar;
+ private System.Windows.Forms.Label label11;
+ private System.Windows.Forms.CheckBox cbGrayscale;
+ private System.Windows.Forms.ComboBox cbDepth;
+ private System.Windows.Forms.Label label12;
+ private System.Windows.Forms.CheckBox cbColor;
}
}
\ No newline at end of file
diff --git a/TBO/UI/Windows/Studio.cs b/TBO/UI/Windows/Studio.cs
index 8e40fea..d3cc71b 100644
--- a/TBO/UI/Windows/Studio.cs
+++ b/TBO/UI/Windows/Studio.cs
@@ -1,19 +1,133 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
+using System.IO;
using System.Windows.Forms;
namespace TBO.UI.Windows
{
public partial class Studio : Form
{
+
public Studio()
{
InitializeComponent();
}
+
+ private string FBytes(double bytes)
+ {
+ string tail = string.Empty;
+ if (bytes > 1024)
+ {
+ bytes /= 1024;
+ tail = " Kb";
+ }
+ if (bytes > 1024)
+ {
+ bytes /= 1024;
+ tail = " Mb";
+ }
+ if (bytes > 1024)
+ {
+ bytes /= 1024;
+ tail = " Gb";
+ }
+ if (bytes > 1024)
+ {
+ bytes /= 1024;
+ tail = " Tb";
+ }
+ if (bytes > 1024)
+ {
+ bytes /= 1024;
+ tail = " Yb";
+ }
+ return bytes.ToString("0.00") + tail;
+ }
+
+ private void btInputDir_Click(object sender, EventArgs e)
+ {
+ FolderBrowserDialog fbd = new FolderBrowserDialog();
+ try
+ {
+ fbd.SelectedPath = tbInputDir.Text;
+ }
+ catch { }
+ if (fbd.ShowDialog() == DialogResult.OK)
+ {
+ tbInputDir.Text = fbd.SelectedPath;
+ tbTBO.Text = Path.Combine(Path.GetDirectoryName(fbd.SelectedPath), Path.GetFileNameWithoutExtension(fbd.SelectedPath)) + ".tbo";
+ }
+ }
+
+ private void btTBO_Click(object sender, EventArgs e)
+ {
+ SaveFileDialog fd = new SaveFileDialog();
+ try
+ {
+ fd.FileName = tbTBO.Text;
+ }
+ catch { }
+ fd.Filter = "Tebeo|*.tbo";
+ fd.DefaultExt = "tbo";
+ if (fd.ShowDialog() == DialogResult.OK)
+ {
+ tbTBO.Text = fd.FileName;
+ }
+ }
+
+ private void btGo_Click(object sender, EventArgs e)
+ {
+ List files;
+ try
+ {
+ files = new List(Directory.GetFiles(tbInputDir.Text));
+ }
+ catch
+ {
+ MessageBox.Show("No se pudo leer el directorio de entrada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ files.Sort();
+ pbGo.Value = 0;
+ pbGo.Maximum = files.Count;
+ pbGo.Style = ProgressBarStyle.Continuous;
+ try
+ {
+ btGo.Enabled = false;
+ TBOFile tbo = new TBOFile(tbTBO.Text);
+ tbo.Title = tbTitle.Text;
+ tbo.Variant = tbVar.Text;
+ tbo.Volume = tbVolume.Text;
+ tbo.Author = tbAuthor.Text;
+ tbo.Publisher = tbPublisher.Text;
+ tbo.Year = (int)nudYear.Value;
+ tbo.Comments = tbCom.Text;
+ if (cbGrayscale.Checked)
+ tbo.Grayscale = new int[] { 256, 16, 8, 6, 4, 2 }[cbDepth.SelectedIndex];
+ else
+ tbo.Grayscale = 0;
+ tbo.KeepColors = cbColor.Checked;
+ for (int i = 0; i < files.Count; i++)
+ {
+ pbGo.Value = i;
+ tbo.AppendImage(files[i], i);
+ lbInfo.Text = FBytes(tbo.Size);
+ Application.DoEvents();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ finally
+ {
+ btGo.Enabled = true;
+ }
+ }
+
+ private void Studio_Load(object sender, EventArgs e)
+ {
+ cbDepth.SelectedIndex = 1;
+ }
}
}
diff --git a/TBO/UI/Windows/Studio.resx b/TBO/UI/Windows/Studio.resx
index 24f56bf..b068194 100644
--- a/TBO/UI/Windows/Studio.resx
+++ b/TBO/UI/Windows/Studio.resx
@@ -119,7 +119,8 @@
Directorio con las imágenes que componen el tebeo.
-Cáda página ha de estar escaneada en una sola imágen, y las páginas han de estar enumeradas secuencialmente en el orden en el que deverán ser leidas.
+Cáda página ha de estar escaneada en una sola imágen, y las páginas han de estar enumeradas secuencialmente en el orden en el que deberían ser leidas.
+Tambien se puede seleccionar un archivo zip o cbz para pasarlo a tbo.
diff --git a/TBO/app.config b/TBO/app.config
new file mode 100644
index 0000000..49cc43e
--- /dev/null
+++ b/TBO/app.config
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file