public ImageManipulator(Bitmap bitmap, ImageManipulatorType.Name filter, ThreadHandler thHandler, int[] values = null ) { this.bitmap = bitmap; this.filter = filter; this.thHandler = thHandler; this.values = values; }
public void filter_RGB_Mode(ImageManipulatorType.Name color) { // letztes zwischengespeichertes Bild holen PixelState state = PixelState.getInstance(); I_ImageObject imgObj = state.get_last(); // Vergleichsliste mit RGB Klassen Typen erstellen List <ImageManipulatorType.Name> container = new List <ImageManipulatorType.Name>(); container.Add(ImageManipulatorType.Name.RGB_BLUE); container.Add(ImageManipulatorType.Name.RGB_RED); container.Add(ImageManipulatorType.Name.RGB_GREEN); // wenn das letzte zwischengespeicherte Bild mit dieser funktion verändert wurde if (container.Contains(imgObj.get_ImageManipulatorType())) { /* dann diese Veränderung rückgängig machen, da ansonsten das Bild schwarz wird. * 2 aufeinander folgende Kanal filter => schwarzes bild, da jeweils 2 Farbkanäle * pro Funktions aufruf auf 0 gesetzt werden. Nach 2 Funktionsaufrufen sind also * alle Kanäle 0 was schwarzes Bild ergibt. */ this.undo(); } state.add(new ImageObject(pic.Image, color)); ThreadHandler thHandler = new ThreadHandler(threads); new ImageManipulator((Bitmap)pic.Image, color, thHandler).perform(); this.show_picture(thHandler); }
public ImageManipulator(Bitmap bitmap, ImageManipulatorType.Name filter, ThreadHandler thHandler, int[] values = null) { this.bitmap = bitmap; this.filter = filter; this.thHandler = thHandler; this.values = values; }
public void performTest1() { Bitmap bitmap = new Bitmap(100, 100); ImageManipulatorType.Name filter = ImageManipulatorType.Name.GRAYSCALE; // TODO: Passenden Wert initialisieren int threads = 2; // TODO: Passenden Wert initialisieren ThreadHandler thHandler = new ThreadHandler(threads); ImageManipulator t = new ImageManipulator(bitmap, filter, thHandler); // TODO: Passenden Wert initialisieren PrivateObject param0 = new PrivateObject(t); // TODO: Passenden Wert initialisieren ImageManipulator_Accessor target = new ImageManipulator_Accessor(param0); BitmapData bmData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int stride = bmData.Stride; int bytes = Math.Abs(bmData.Stride) * bmData.Height; System.IntPtr Scan0 = bmData.Scan0; target.perform(Scan0, stride); // Die Funktion stößt nur andere Funktionen ab hier an. Was testen? bitmap.UnlockBits(bmData); }
public void filter(ImageManipulatorType.Name name) { PixelState.getInstance().add(new ImageObject(pic.Image, name)); ThreadHandler thHandler = new ThreadHandler(threads); new ImageManipulator((Bitmap)pic.Image, name, thHandler).perform(); this.show_picture(thHandler); }
public void RGB_ModeFilterConstructorTest() { Bitmap b = new Bitmap(10, 10); IntPtr Scan0 = new IntPtr(); // TODO: Passenden Wert initialisieren int stride = 0; // TODO: Passenden Wert initialisieren int height_start = 0; // TODO: Passenden Wert initialisieren int height_end = 0; // TODO: Passenden Wert initialisieren ThreadHandler thInfo = null; // TODO: Passenden Wert initialisieren ImageManipulatorType.Name color_type = new ImageManipulatorType.Name(); // TODO: Passenden Wert initialisieren RGB_ModeFilter target = new RGB_ModeFilter(b, Scan0, stride, height_start, height_end, thInfo, color_type); }
public void RGB_ModeFilterConstructorTest() { Bitmap b = new Bitmap(10, 10); IntPtr Scan0 = new IntPtr(); // TODO: Passenden Wert initialisieren int stride = 0; // TODO: Passenden Wert initialisieren int height_start = 0; // TODO: Passenden Wert initialisieren int height_end = 0; // TODO: Passenden Wert initialisieren ThreadHandler thInfo = null; // TODO: Passenden Wert initialisieren ImageManipulatorType.Name color_type = new ImageManipulatorType.Name(); // TODO: Passenden Wert initialisieren RGB_ModeFilter target = new RGB_ModeFilter(b, Scan0, stride, height_start, height_end, thInfo, color_type); }
public void ImageObjectConstructorTest() { Bitmap b = new Bitmap(10, 10); Image img = (Image)b; ImageManipulatorType.Name manipulator = ImageManipulatorType.Name.RGB_RED; // TODO: Passenden Wert initialisieren ImageObject target = new ImageObject(img, manipulator); Assert.AreEqual(target.get_ImageManipulatorType(), ImageManipulatorType.Name.RGB_RED); Assert.AreSame(target.get_Image(), img); Assert.IsInstanceOfType(target.get_Image(), typeof(Image)); }
public void get_ImageTest() { Bitmap b = new Bitmap(10, 10); Image img = (Image)b; ImageManipulatorType.Name manipulator = ImageManipulatorType.Name.RGB_RED; // TODO: Passenden Wert initialisieren ImageObject target = new ImageObject(img, manipulator); // TODO: Passenden Wert initialisieren Image actual = target.get_Image(); Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(Image)); }
public void get_ImageManipulatorTypeTest() { Image img = new Bitmap(1, 1); PictureBox pic = new PictureBox(); pic.Image = img; NullImageObject target = new NullImageObject(pic); ImageManipulatorType.Name expected = ImageManipulatorType.Name.DEFAULT; ImageManipulatorType.Name actual; actual = target.get_ImageManipulatorType(); Assert.AreEqual(expected, actual); }
public void performTest() { Bitmap bitmap = new Bitmap(10, 10); ImageManipulatorType.Name filter = ImageManipulatorType.Name.GRAYSCALE; // TODO: Passenden Wert initialisieren int threads = 2; // TODO: Passenden Wert initialisieren ThreadHandler thHandler = new ThreadHandler(threads); ImageManipulator target = new ImageManipulator(bitmap, filter, thHandler); // TODO: Passenden Wert initialisieren bool expected = true; // TODO: Passenden Wert initialisieren bool actual = target.perform(); Assert.AreEqual(expected, actual); }
public void save_PixelStateTest() { int threads = 0; // TODO: Passenden Wert initialisieren ThreadHandler target = new ThreadHandler(threads); // TODO: Passenden Wert initialisieren Bitmap b = new Bitmap(10, 10); Image img = (Image)b; ImageManipulatorType.Name manipulator = ImageManipulatorType.Name.RGB_RED; // TODO: Passenden Wert initialisieren ImageObject imgO = new ImageObject(img, manipulator); target.save_PixelState(imgO); PixelState state = PixelState.getInstance(); Assert.IsInstanceOfType(state, typeof(PixelState)); }
public void ImageManipulatorConstructorTest() { Bitmap bitmap = new Bitmap(10, 10); ImageManipulatorType.Name filter = ImageManipulatorType.Name.GRAYSCALE; // TODO: Passenden Wert initialisieren int threads = 2; // TODO: Passenden Wert initialisieren ThreadHandler thHandler = new ThreadHandler(threads); ImageManipulator t = new ImageManipulator(bitmap, filter, thHandler); // TODO: Passenden Wert initialisieren PrivateObject param0 = new PrivateObject(t); // TODO: Passenden Wert initialisieren ImageManipulator_Accessor target = new ImageManipulator_Accessor(param0); Assert.IsNotNull(target.bitmap); Assert.IsNotNull(target.thHandler); Assert.IsNotNull(target.filter); }
public void computeHeightStepsTest() { Bitmap bitmap = new Bitmap(10, 10); ImageManipulatorType.Name filter = ImageManipulatorType.Name.GRAYSCALE; // TODO: Passenden Wert initialisieren int threads = 2; // TODO: Passenden Wert initialisieren ThreadHandler thHandler = new ThreadHandler(threads); ImageManipulator t = new ImageManipulator(bitmap, filter, thHandler); // TODO: Passenden Wert initialisieren PrivateObject param0 = new PrivateObject(t); // TODO: Passenden Wert initialisieren ImageManipulator_Accessor target = new ImageManipulator_Accessor(param0); int height = 10; // TODO: Passenden Wert initialisieren int expected = 5; // TODO: Passenden Wert initialisieren int actual; actual = target.computeHeightSteps(height); Assert.AreEqual(expected, actual); }
public void try_save_PixelStateTest() { ThreadHandler t = new ThreadHandler(2); PrivateObject param0 = new PrivateObject(t); ThreadHandler_Accessor target = new ThreadHandler_Accessor(param0); // TODO: Passenden Wert initialisieren Bitmap b = new Bitmap(10, 10); Image img = (Image)b; ImageManipulatorType.Name manipulator = ImageManipulatorType.Name.RGB_RED; // TODO: Passenden Wert initialisieren ImageObject imgO = new ImageObject(img, manipulator); target.try_save_PixelState(imgO); PixelState state = PixelState.getInstance(); Assert.IsInstanceOfType(state.get_last(), typeof(ImageObject)); Assert.IsNotNull(state.get_last()); }
public override Manipulate create(ImageManipulatorType.Name name, Bitmap bitmap, System.IntPtr Scan0, int stride, int height_start, int height_end, ThreadHandler thHandler, int[] values) { switch (name) { case ImageManipulatorType.Name.INVERT: return(new InvertFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.OSCILLATION: return(new OscillationFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.GRAYSCALE: return(new GrayscaleFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.BLACKWHITE: return(new BlackWhiteFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.ERROR_DIFFUSION: return(new ErrorDiffusionFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.SEPIA: return(new SepiaFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.SAMPLE_BOARD: return(new SampleBoardFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, values)); case ImageManipulatorType.Name.RGB_RED: return(new RGB_ModeFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, ImageManipulatorType.Name.RGB_RED)); case ImageManipulatorType.Name.RGB_GREEN: return(new RGB_ModeFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, ImageManipulatorType.Name.RGB_GREEN)); case ImageManipulatorType.Name.RGB_BLUE: return(new RGB_ModeFilter(bitmap, Scan0, stride, height_start, height_end, thHandler, ImageManipulatorType.Name.RGB_BLUE)); } throw (new FilterUndefinedException("Selected filter is not defined in FilterFactory class!")); }
public void get_ImageManipulatorTypeTest() { Bitmap b = new Bitmap(10, 10); Image img = (Image)b; ImageManipulatorType.Name manipulator = ImageManipulatorType.Name.ERROR_DIFFUSION; ImageObject target = new ImageObject(img, manipulator); ImageManipulatorType.Name expected = ImageManipulatorType.Name.ERROR_DIFFUSION; ImageManipulatorType.Name actual; actual = target.get_ImageManipulatorType(); Assert.AreEqual(expected, actual); manipulator = ImageManipulatorType.Name.BLACKWHITE; target = new ImageObject(img, manipulator); actual = target.get_ImageManipulatorType(); Assert.AreNotEqual(expected, actual); }
public void createTest() { FilterFactory target = new FilterFactory(); // TODO: Passenden Wert initialisieren ImageManipulatorType.Name name = ImageManipulatorType.Name.INVERT; Bitmap bitmap = new Bitmap(1, 1); IntPtr Scan0 = new IntPtr(); // TODO: Passenden Wert initialisieren int stride = 0; // TODO: Passenden Wert initialisieren int height_start = 0; // TODO: Passenden Wert initialisieren int height_end = 0; // TODO: Passenden Wert initialisieren ThreadHandler thHandler = null; // TODO: Passenden Wert initialisieren int[] values = null; // TODO: Passenden Wert initialisieren Manipulate expected = null; // TODO: Passenden Wert initialisieren Manipulate actual; actual = target.create(name, bitmap, Scan0, stride, height_start, height_end, thHandler, values); Assert.AreNotEqual(expected, actual); Assert.IsInstanceOfType(actual, typeof(Manipulate)); }
public ImageObject(Image img, ImageManipulatorType.Name manipulator) { // TODO: Complete member initialization this.img = img; this.manipulator = manipulator; }
public RGB_ModeFilter(Bitmap b, System.IntPtr Scan0, int stride, int height_start, int height_end, ThreadHandler thInfo, ImageManipulatorType.Name color_type) : base(b, Scan0, stride,height_start, height_end, thInfo) { this.color_type = color_type; }
public RGB_Mode(Bitmap b, System.IntPtr Scan0, int stride, int height_start, int height_end, ThreadHandler thInfo, ImageManipulatorType.Name color_type) : base(b, Scan0, stride, height_start, height_end, thInfo) { this.color_type = color_type; }
public ImageObject(Image img, ImageManipulatorType.Name manipulator) { // TODO: Complete member initialization this.img = img; this.manipulator = manipulator; }
public void filter_rotate(RotateFlipType type) { ImageManipulatorType.Name name = ImageManipulatorType.Name.ROTATE; PixelState.getInstance().add(new ImageObject(pic.Image, name)); RotateFilter.rotate((Bitmap)pic.Image, type); }
/* * public Manipulate perform(ImageManipulatorType.Name name, Bitmap bitmap, System.IntPtr Scan0, int stride, int height_start, int height_end, ThreadHandler thHandler, int[] values) * { * * return create(name, bitmap, Scan0, stride, height_start, height_end, thHandler, values); * } */ public abstract Manipulate create(ImageManipulatorType.Name name, Bitmap bitmap, System.IntPtr Scan0, int stride, int height_start, int height_end, ThreadHandler thHandler, int[] values);