public static Type GetImageFileTypeFromSignature(byte[] buffer) { if (TEXN.IsValid(buffer)) { return(typeof(TEXN)); } if (PVRT.IsValid(buffer)) { return(typeof(PVRT)); } if (DDS.IsValid(buffer)) { return(typeof(DDS)); } if (BMP.IsValid(buffer)) { return(typeof(BMP)); } if (JPEG.IsValid(buffer)) { return(typeof(JPEG)); } if (PNG.IsValid(buffer)) { return(typeof(PNG)); } return(null); }
/// <summary> /// Creates the image data /// </summary> public void CreateImage() { double bmpXStep = 1.0 / (double)(BMP.Width - 1); double bmpYStep = 1.0 / (double)(BMP.Height - 1); int xCoord, yCoord; for (int x = 0; x < TransformedUVCoords.GetLength(0); x++) { for (int y = 0; y < TransformedUVCoords.GetLength(1); y++) { xCoord = (int)Math.Floor(TransformedUVCoords[y, x].U / bmpXStep); yCoord = (int)Math.Floor(TransformedUVCoords[y, x].V / bmpYStep); ResultBMP.SetPixel(x, y, BMP.GetPixel(xCoord, yCoord)); } } if (TreePathData == null) { createFolderFileWMTS(); } else { createFolderFileTREE(); } }
public static void Main(string[] args) { string filename = args[0]; string palettename = args[1]; Console.WriteLine("grp file {0}", filename); Console.WriteLine("palette file {0}", palettename); FileStream fs = File.OpenRead(filename); Grp grp = new Grp(); ((MpqResource)grp).ReadFromStream(fs); Pcx pal = new Pcx(); pal.ReadFromStream(File.OpenRead(palettename), -1, -1); for (int i = 0; i < grp.FrameCount; i++) { BMP.WriteBMP(String.Format("output{0:0000}.bmp", i), grp.GetFrame(i), grp.Width, grp.Height, pal.Palette); } }
/// <summary> /// This function enabels you to hide a message insider a BMP /// </summary> /// <param name="inputPath">input BMP path</param> /// <param name="outputPath">output BMP path</param> /// <param name="message">message to hide</param> public void HideMessage(string inputPath, string outputPath, string message) { int readByte; int count = 14; BMP bitmap = new BMP(inputPath); bitmap.BitmapFileHeader.bfOffBits += (message.Length + 1); bitmap.BitmapFileHeader.bfSize += (message.Length + 1); FileStream br = new FileStream(inputPath, FileMode.Open); BinaryWriter bw = new BinaryWriter(File.OpenWrite(outputPath)); bitmap.WriteBMPFileHeader(bw); br.Seek(14, SeekOrigin.Begin); while (count < (bitmap.BitmapFileHeader.bfOffBits - (message.Length + 1))) { bw.Write((byte)br.ReadByte()); count++; } for (int i = 0; i < message.Length; i++) { bw.Write(message[i]); } bw.Write(Convert.ToByte(message.Length)); while ((readByte = br.ReadByte()) >= 0) { bw.Write((byte)readByte); } bw.Close(); br.Close(); }
private cType getSettings() { if (radioButtonDDS.Checked) { int bits = radioButton8Bit.Checked ? 8 : radioButton16Bit.Checked ? 16 : radioButton32Bit.Checked ? 32: 0; DDS outp = new DDS(bits, inp.Width, inp.Height, inp.Depth, 0, 0, 0); outp.Compressed = radioButtonCompressed.Checked; if (comboBoxFormat.SelectedItem != null) { outp.FormatName = (ParsedBitmap.BitmapFormat)Enum.Parse(typeof(ParsedBitmap.BitmapType), "BITM_FORMAT_" + comboBoxFormat.SelectedItem.ToString()); } return(outp); } else if (radioButtonJpeg.Checked) { JPG outp = new JPG(); return(outp); } else if (radioButtonBitmap.Checked) { BMP outp = new BMP(); return(outp); } return(null); }
private void SaveThumbImg(Image img) { ThumbSave.Enabled = true; byte[] bdata; using (var mem = new MemoryStream()) { img.Save(mem, ImageFormat.Bmp); bdata = mem.ToArray(); } var existing = ActiveObj.Resource.Get <BMP>(ActiveObj.OBJ.CatalogStringsID); var isNew = (existing == null); if (isNew) { existing = new BMP(); existing.ChunkParent = ActiveObj.Resource.MainIff; existing.ChunkProcessed = true; existing.ChunkID = ActiveObj.OBJ.CatalogStringsID; existing.ChunkLabel = ""; } Content.Content.Get().Changes.BlockingResMod(new ResAction(() => { existing.data = bdata; existing.ChunkParent.AddChunk(existing); if (isNew) { existing.AddedByPatch = true; } existing.RuntimeInfo = ChunkRuntimeState.Modified; }, existing)); }
protected static BMP GetData(Bitmap bmp) { var newBmp = new BMP(); newBmp.Width = bmp.Width; newBmp.Height = bmp.Height; newBmp.PixelFormat = bmp.PixelFormat; // Lock the bitmap's bits. Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat); // Get the address of the first line. IntPtr ptr = bmpData.Scan0; // Declare an array to hold the bytes of the bitmap. int bytes = Math.Abs(bmpData.Stride) * bmp.Height; newBmp.Stride = Math.Abs(bmpData.Stride); byte[] rgbValues = new byte[bytes]; newBmp.Data = rgbValues; // Copy the RGB values into the array. System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); // Unlock the bits. bmp.UnlockBits(bmpData); return(newBmp); }
public static void Main(string[] args) { #region Observer Pattern Book b = new Book("The lord of the rings"); var l = new Librarian(); var g = new Grocer(); var r = new Restorer(); b.addObserver(l); b.addObserver(g); b.addObserver(r); b.Notify(); Console.WriteLine("---------------------------------------------------------"); #endregion #region Factory Method Pattern MyApplication app = new MyApplication(); var doc = app.createDocument(); doc.Open(); Console.WriteLine("---------------------------------------------------------"); #endregion #region Bridge Pattern AbstractPicture img = new JPG(new OSXImp()); img.Caller(); img = new BMP(new WinImp()); img.Caller(); img = new GIF(new LinuxImp()); img.Caller(); Console.WriteLine("---------------------------------------------------------"); #endregion #region Abstract Factory Pattern // THIS IS THE CLIENT CLASS CONTENT MENTIONED ON PATTERN PRINCIPLES. IFactory factory = new PMFactory(); IScrollbar scrollbar = factory.BuildScrollbar(); IWindow window = factory.BuildWindow(); scrollbar.Draw(); window.Draw(); Console.WriteLine("\n"); factory = new MOTIFFactory(); scrollbar = factory.BuildScrollbar(); window = factory.BuildWindow(); scrollbar.Draw(); window.Draw(); Console.WriteLine("---------------------------------------------------------"); #endregion #region Adapter Pattern var oldcar = new OldCar("Chevrolet", "Impala", new DateTime(1967, 1, 1)); var adapter = new OldNewAdapter(oldcar); Console.WriteLine(adapter.getBrand()); Console.WriteLine(adapter.getYears()); Console.WriteLine("---------------------------------------------------------"); #endregion }
private void cbBMP_SelectedIndexChanged(object sender, EventArgs e) { BMP bmp = currentCatchment().getBMP(Common.getString(cbBMP)); if (bmp.hasMediaMix()) { Common.setValue(cbMixes, bmp.MediaMixType.Replace('_', '&')); } }
private void cbBMP_SelectedIndexChanged(object sender, EventArgs e) { Common.setValue(tbTD, GetAnnualOP(), 3); BMP bmp = currentCatchment().getBMP(Common.getString(cbBMP)); Common.setValue(tbRate, MediaMix.SorptionRate(bmp.MediaMixType), 2); //tbRate.Enabled = false; Common.setValue(tbMediaWeight, MediaMix.SaturatedWeight(bmp.MediaMixType)); //tbMediaWeight.Enabled = false; Common.setValue(tbFilterVolume, bmp.MediaVolume); GetValues(); }
private static void Blit(BMP src, BMP dst) { if (src.Width == dst.Width && src.Height == dst.Height) { Blit_Same(src, dst); } else { Blit_Any(src, dst); } }
private void SetChartArea(ChartArea ca, BMP bmp) { ca.AxisX.LabelStyle.Angle = -90; ca.AxisX.Title = bmp.XAxisTitle(); ca.AxisY.Title = bmp.YAxisTitle(); ca.AxisX.Minimum = bmp.XAxisMinimum(); ca.AxisX.Maximum = bmp.XAxisMaximum(); ca.AxisY.Minimum = bmp.YAxisMinimum(); ca.AxisY.Maximum = bmp.YAxisMaximum(); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.Default; Console.WriteLine($"\u001b[38;2;128;20;196m\u2580\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u2590\u2591\u2592\u2593\u2594\u2595\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F\u2615\u26Be\u001b[38;2;128;128;128m"); Console.WriteLine($"\u001b[38;2;128;20;196m\u2580\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u2590\u2591\u2592\u2593\u2594\u2595\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F\u2615\u26Be\u001b[38;2;128;128;128m"); Console.WriteLine($"\u001b[38;2;128;20;196m\u2580\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u2590\u2591\u2592\u2593\u2594\u2595\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F\u2615\u26Be\u001b[38;2;170;170;170m"); Console.WriteLine("▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟☕⚾"); MP3 mp3 = new MP3(); //mp3.Decode($@"C:\Users\johnr\Downloads\MBR\warez.zip\Mp3\Contra.mp3"); mp3.Decode($@"C:\Users\johnr\Documents\outputWave1-ABR-192.mp3"); return; DirectoryInfo directoryInfo = new DirectoryInfo($@"c:\users\johnr\pictures"); //foreach (var file in directoryInfo.GetFiles()) //{ // if (new string[] { ".jpg", ".jpeg", ".jfif" }.Contains(file.Extension.ToLower())) // { // Console.WriteLine($"File: {file.FullName}"); // JPEG jpg = new JPEG(file.FullName); // } //} //JPEG jpeg = new JPEG($@"c:\users\johnr\pictures\Calculator1.jpg"); JPEG jpeg = new JPEG($@"c:\users\johnr\pictures\68518b2cd5485d576cc34355ffb0027d.jpg"); return; GIF gif = new GIF($@"c:\users\johnr\pictures\Calculator1.gif"); LZW lzw = new LZW(); BMP bmp = new BMP($@"c:\users\johnr\pictures\3Sphere_2c.bmp"); directoryInfo = new DirectoryInfo($@"c:\users\johnr\pictures"); foreach (var file in directoryInfo.GetFiles()) { if (file.Extension.ToLower() == ".png") { Console.WriteLine($"File: {file.FullName}"); PNG png = new PNG(file.FullName); var header = png.DataChunks.Where(x => x.ChunkType.ToLower() == "ihdr").FirstOrDefault(); var properties = (header.DataChunkRepresentation as PNG.DataChunk.HeaderChunkRepresentation).ToProperties(header.Data); //if ((byte)properties["ColorType"].Value == 6) // Console.ReadLine(); } } //Console.WriteLine("Enter PNG Filename:"); //string path = Console.ReadLine(); //PNG png = new PNG(path); }
unsafe static void Blit_Same(BMP src, BMP dst) { int *sp = src.Data + src.Width * (src.Height - 1); int *dp = dst.Data; for (int j = 0; j < src.Height; j++) { for (int i = 0; i < src.Width; i++) { dp[i] = sp[i]; } sp -= src.Width; dp += src.Width; } }
private void ImgOpen_Click(object sender, RoutedEventArgs e) { string filename = FileDialog_Open("image files (*.png;*.jpg;*.bmp)|*.png;*.jpg;*.bmp"); if (filename == null) { return; } SourceImage = new BMP(filename); image.Source = SourceImage.ExportSource(); isSaved = false; }
public Bitmap(string file) { ReadStream stream = new ReadStream(File.ReadAllBytes(file)); string extension = Path.GetExtension(file); switch (extension.ToLower()) { case ".bmp": BMP.Decode(stream, this); break; case ".png": PNG.Decode(stream, this); break; default: Debug.Assert(false, "Image file extension not supported: {0}", extension); break; } }
/// <summary> /// Retrives a hidden message from a BMP /// </summary> /// <param name="path">path of BMP</param> /// <returns>the hidden message</returns> public string RetrieveMessage(string path) { int length; StringBuilder message = new StringBuilder(); BinaryReader br = new BinaryReader(File.OpenRead(path)); BMP bitmap = new BMP(path); br.BaseStream.Seek(bitmap.BitmapFileHeader.bfOffBits - 1, SeekOrigin.Begin); length = (int)br.ReadByte(); br.BaseStream.Seek(-(length + 1), SeekOrigin.Current); message.Append(br.ReadChars(length)); br.Close(); return(message.ToString()); }
static void Main(string[] args) { if (args.Length != 3) { throw new Exception("Invalid input"); } if (args[0].Substring(args[0].LastIndexOf('.')) != ".bmp" || args[1].Substring(args[1].LastIndexOf('.')) != ".bmp") { throw new Exception("Invalid file type! Files have to be bmp"); } BMP bmp = new BMP(); bmp.ReadBMP(args[0]); Filters Filter = new Filters(); if (args[2] == "Grey") { Filter.Grey(bmp.pixels, bmp.HeaderInfoBMP.Height, bmp.HeaderInfoBMP.Width); } else if (args[2] == "Gauss") { Filter.Filter(bmp.pixels, bmp.HeaderInfoBMP.Height, bmp.HeaderInfoBMP.Width, (uint)FiltersName.Gauss); } else if (args[2] == "Averaging") { Filter.Filter(bmp.pixels, bmp.HeaderInfoBMP.Height, bmp.HeaderInfoBMP.Width, (uint)FiltersName.Averaging); } else if (args[2] == "SobelX") { Filter.Filter(bmp.pixels, bmp.HeaderInfoBMP.Height, bmp.HeaderInfoBMP.Width, (uint)FiltersName.SobelX); } else if (args[2] == "SobelY") { Filter.Filter(bmp.pixels, bmp.HeaderInfoBMP.Height, bmp.HeaderInfoBMP.Width, (uint)FiltersName.SobelY); } else { throw new ArgumentException("Entered wrong name of filter"); } bmp.WriteBMP(args[1]); Console.WriteLine("Success"); }
public void Save(string file) { string extension = Path.GetExtension(file); byte[] data = null; switch (extension.ToLower()) { case ".bmp": data = BMP.Encode(this); break; case ".png": data = PNG.Encode(this); break; default: Debug.Assert(false, "Image file extension not supported: {0}", extension); break; } File.WriteAllBytes(file, data); }
public cType convert(cType inputType) { Bitmap bm = null; // Decoding section if (inputType is DDS) { //bm = DDSRead(inputType as DDS); DDSConvert(inp, outp); } else if (inputType is JPG) { bm = new Bitmap(inputType.stream); } else if (inputType is BMP) { bm = new Bitmap(inputType.stream); } // Encoding section bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp); if (outp is DDS) { DDS inp = inputType as DDS; //switch (formats) { } return(outp); } else if (outp is JPG) { cType outputType = new JPG(); bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Jpeg); return(outputType); } else if (outp is BMP) { cType outputType = new BMP(); bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp); return(outputType); } return(null); }
private static unsafe void Blit_Any_NoFlip(BMP src, BMP dst) { int w = dst.Width; int h = dst.Height; int in_w = src.Width; int in_h = src.Height; int *sp = src.Data; int *dp = dst.Data; for (int j = 0; j < h; j++) { sp = src.Data + in_w * (j * in_h / h); for (int i = 0; i < w; i++) { dp[i] = sp[i * in_w / w]; } dp += w; } }
private void Check(BMP expected, BMP actual) { Assert.AreEqual(expected.HeaderInfoBMP.Height, actual.HeaderInfoBMP.Height); Assert.AreEqual(expected.HeaderInfoBMP.Width, actual.HeaderInfoBMP.Width); byte[,,] ExpectedPixels = new byte[expected.HeaderInfoBMP.Height, expected.HeaderInfoBMP.Width, 3]; byte[,,] ActualPixels = new byte[actual.HeaderInfoBMP.Height, actual.HeaderInfoBMP.Width, 3]; for (int i = 0; i < expected.HeaderInfoBMP.Height; i++) { for (int j = 0; j < expected.HeaderInfoBMP.Width; j++) { for (int k = 0; k < 3; k++) { Assert.AreEqual(ExpectedPixels[i, j, k], ActualPixels[i, j, k]); } } } }
private void PlotStorage(BMP bmp) { chart1.Series.Clear(); Series series1 = new Series { Name = "default", Color = System.Drawing.Color.Blue, ChartType = SeriesChartType.Line }; chart1.Titles.Add("Title"); chart1.Titles[0].Text = "Plot of Retention Storage Curve"; chart1.Series.Add(series1); addXY(21, chart1.Series["default"], bmp.plotX(), bmp.plotY()); chart1.Series[0].LegendText = bmp.LegendTitle(); SetChartArea(chart1.ChartAreas[0], bmp); }
static void Test() { BMP bmp = new BMP(); byte[] data = bmp.GetPixels("0:\\test.bmp", false); int width = bmp.width; int height = bmp.height; for (int x = 0; x < bmp.width; x++) { for (int y = 0; y < bmp.height; y++) { int R = data[x * width + y]; int G = data[x * width + y + 1]; int B = data[x * width + y + 2]; int RGB = int.Parse(R.ToString() + G.ToString() + B.ToString()); //You now have a RGB pixel here! You can set this in Cosmos in VGA or VBE by passing it to the c argument in SetPixel. } } }
unsafe static void Blit_Any(BMP src, BMP dst) { int w = dst.Width; int h = dst.Height; int in_w = src.Width; int in_h = src.Height; int *sp = src.Data; int *dp = dst.Data; // vflip along the way for (int j = h - 1; j >= 0; j--) { sp = src.Data + in_w * (j * in_h / h); for (int i = 0; i < w; i++) { dp[i] = sp[i * in_w / w]; } dp += w; } }
private static unsafe void Blit_Any(BMP src, BMP dst) { int w = dst.Width; int h = dst.Height; int inW = src.Width; int inH = src.Height; int *sp = src.Data; int *dp = dst.Data; // vflip along the way for (int j = h - 1; j >= 0; j--) { sp = src.Data + (inW * (j * inH / h)); for (int i = 0; i < w; i++) { dp[i] = sp[i * inW / w]; } dp += w; } }
private void PrintResults() { BMP bmp = currentCatchment().getBMP(Common.getString(cbBMP)); string s = "<h1>Media Filter Report</h1>"; //s += "Catchment Name: Catchment " + SelectedCatchment.ToString() + "<br/>"; if (bmp != null) { s += "Treatment Depth (in): " + Common.getString(bmp.RetentionDepth, 2) + "<br/>"; } // s += " Phosphorus Into Media Per Year (kg/yr): " + Common.getString(AnnualOP, 2) + "<br/>"; s += " Phosphorus Removed per Year (kg OP/yr): " + Common.getString(OPRemoved / 1e6, 2) + "<br/>"; s += " Filter Capacity (kg OP): " + Common.getString(OPCapacity / 1e6, 2) + "<br/>"; s += " Sorption Rate (mg OP/g media): " + Common.getString(SorptionRate, 2) + "<br/>"; s += " Filter Volume Provided (cf): " + Common.getString(FilterVolumeProvided, 2) + "<br/>"; s += " Saturated Weight of Media (lbs/cf): " + Common.getString(SaturatedWeight, 2) + "<br/>"; s += " Filter OP in TP (fraction): " + Common.getString(FractionOP, 2) + "<br/>"; s += " Service Life (years): " + Common.getString(ServiceLife, 1) + "<br/>"; //s += " Filter Volume for 30 Years Service Life (cf): " + Common.getString(FilterVolume30Years, 0) + "<br/>"; wbOutput.DocumentText = s; }
private double GetAnnualOP() { SelectedCatchment = Convert.ToInt32(cbTo.SelectedValue); if (SelectedCatchment == 0) { return(0.0); } Catchment c = Globals.Project.getCatchment(SelectedCatchment); if (Common.getString(cbBMP) == "") { return(0.0); } BMP bmp = c.getBMP(Common.getString(cbBMP)); bmp.Calculate(); Common.setValue(tbTD, bmp.PRetained, 3); if (bmp.BMPType == BMPTrainsProject.sRainGarden) { RainGarden rg = (RainGarden)bmp; Common.setValue(tbFilterVolume, rg.MediaVolume); //return bmp.BMPPMassLoadIn - bmp.BMPPMassLoadOut - bmp.GroundwaterPMassLoadOut; return(bmp.PRetained); } if (bmp.BMPType == BMPTrainsProject.sFiltration) { return(bmp.BMPPMassLoadIn * bmp.ProvidedPTreatmentEfficiency / 100); } //& (bmp.gr)) return bmp.PRetained; // return(bmp.PRetained); return(bmp.BMPPMassLoadOut * bmp.MediaPPercentReduction / 100); }
public frmChart(DomainCode.BMP _bmp, string BMPType) { InitializeComponent(); ChartType = BMPType; bmp = _bmp; if (BMPType == "Storage") { PlotStorage(bmp); } if (BMPType == "VNB") { PlotVNB((VegetatedNaturalBuffer)bmp, "Nitrogen"); } if (BMPType == "VFS") { PlotVFS((VegetatedFilterStrip)bmp, "Nitrogen"); } if (BMPType == "WetDetention") { PlotWetDetention((WetDetention)bmp, "Nitrogen"); } }
public cType convert(cType inputType) { Bitmap bm = null; // Decoding section if (inputType is DDS) { //bm = DDSRead(inputType as DDS); DDSConvert(inp, outp); } else if (inputType is JPG) bm = new Bitmap(inputType.stream); else if (inputType is BMP) bm = new Bitmap(inputType.stream); // Encoding section bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp); if (outp is DDS) { DDS inp = inputType as DDS; //switch (formats) { } return outp; } else if (outp is JPG) { cType outputType = new JPG(); bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Jpeg); return outputType; } else if (outp is BMP) { cType outputType = new BMP(); bm.Save(outp.stream, System.Drawing.Imaging.ImageFormat.Bmp); return outputType; } return null; }
protected static byte[] GetPixel(int x, int y, BMP bmp) { var pixel = new byte[] { 0, 0, 0, 0 }; var s = bmp.Stride; var p = 0; switch (bmp.PixelFormat) { //case Format32bppPArgb case PixelFormat.Format24bppRgb: p = x * 3 + y * s; pixel[0] = bmp.Data[p + 2]; // R pixel[1] = bmp.Data[p + 1]; // G pixel[2] = bmp.Data[p + 0]; // B pixel[3] = 1; // A break; case PixelFormat.Format32bppArgb: p = x * 4 + y * s; pixel[0] = bmp.Data[p + 2]; pixel[1] = bmp.Data[p + 1]; pixel[2] = bmp.Data[p + 0]; pixel[3] = bmp.Data[p + 3]; break; case PixelFormat.Format32bppRgb: p = x * 4 + y * s; pixel[0] = bmp.Data[p + 2]; pixel[1] = bmp.Data[p + 1]; pixel[2] = bmp.Data[p + 0]; pixel[3] = 1; break; } return(pixel); }
private cType getSettings() { if (radioButtonDDS.Checked) { int bits = radioButton8Bit.Checked ? 8 : radioButton16Bit.Checked ? 16 : radioButton32Bit.Checked ? 32: 0; DDS outp = new DDS(bits, inp.Width, inp.Height, inp.Depth, 0, 0, 0); outp.Compressed = radioButtonCompressed.Checked; if (comboBoxFormat.SelectedItem != null) outp.FormatName = (ParsedBitmap.BitmapFormat) Enum.Parse(typeof(ParsedBitmap.BitmapType), "BITM_FORMAT_" + comboBoxFormat.SelectedItem.ToString()); return outp; } else if (radioButtonJpeg.Checked) { JPG outp = new JPG(); return outp; } else if (radioButtonBitmap.Checked) { BMP outp = new BMP(); return outp; } return null; }