public void TestImagePersistence() { // Setup the test Bitmap bitmap1 = FrameGenerator.GenerateRandomBitmap(48, 37, 0); Bitmap bitmap2 = FrameGenerator.GenerateRandomBitmap(12, 45, 0); Stream stream = new MemoryStream(); // Test the methods PersistenceHelper.SaveImageToStream(bitmap1, stream); PersistenceHelper.SaveImageToStream(bitmap2, stream); // Reset stream stream.Position = 0; // Load the bitmaps back up again one at a time Bitmap loadedBitmap1 = PersistenceHelper.LoadImageFromStream(stream); Bitmap loadedBitmap2 = PersistenceHelper.LoadImageFromStream(stream); // Compare images Assert.IsTrue(ImageUtilities.ImagesAreIdentical(bitmap1, loadedBitmap1), "An image loaded from a stream must match completely the image that was saved"); Assert.IsTrue(ImageUtilities.ImagesAreIdentical(bitmap2, loadedBitmap2), "An image loaded from a stream must match completely the image that was saved"); // Try to edit the loaded bitmaps to verify editability loadedBitmap1.SetPixel(0, 0, Color.Black); loadedBitmap2.SetPixel(0, 0, Color.Black); }
public void TestSourceCopyTransparentOperation() { Bitmap target = FrameGenerator.GenerateRandomBitmap(64, 64, 10); PencilPaintOperation operation = new PencilPaintOperation(target, true) { Color = Color.FromArgb(127, 0, 0, 0), CompositingMode = CompositingMode.SourceCopy }; operation.StartOpertaion(); operation.MoveTo(5, 5); operation.DrawTo(10, 10); operation.DrawTo(15, 17); operation.DrawTo(20, 25); operation.DrawTo(25, 37); operation.FinishOperation(); // Hash of the .png image that represents the target result of the paint operation. Generated through the 'RegisterResultBitmap' method byte[] goodHash = { 0x7C, 0xB0, 0xE9, 0x83, 0x12, 0xC3, 0x13, 0x74, 0x20, 0xCA, 0x40, 0x8E, 0x27, 0x11, 0x8B, 0xF5, 0xE9, 0x5F, 0x33, 0x41, 0xCE, 0x7D, 0x8D, 0x74, 0x76, 0x5C, 0xA6, 0xD1, 0xAB, 0x90, 0x1C, 0x34 }; byte[] currentHash = GetHashForBitmap(target); RegisterResultBitmap(target, "PencilOperation_SourceCopyTransparentPaint"); Assert.IsTrue(goodHash.SequenceEqual(currentHash), "The hash for the paint operation does not match the good hash stored. Verify the output image for an analysis of what went wrong"); }
public void TestSourceOverTransparentOperation() { Bitmap target = FrameGenerator.GenerateRandomBitmap(64, 64, 10); PencilPaintOperation operation = new PencilPaintOperation(target) { Color = Color.FromArgb(127, 0, 0, 0), CompositingMode = CompositingMode.SourceOver }; operation.StartOpertaion(); operation.MoveTo(5, 5); operation.DrawTo(10, 10); operation.DrawTo(15, 17); operation.DrawTo(20, 25); operation.DrawTo(25, 37); operation.DrawTo(5, 5); operation.FinishOperation(); // Hash of the .png image that represents the target result of the paint operation. Generated through the 'RegisterResultBitmap' method byte[] goodHash = { 0x7D, 0xBB, 0x8A, 0xAE, 0x0, 0x75, 0x55, 0x54, 0x67, 0xE1, 0x35, 0x90, 0xE2, 0x77, 0xD3, 0xF1, 0xE4, 0xAD, 0xE2, 0xD6, 0xB, 0xDA, 0xCA, 0xB9, 0xDD, 0x64, 0x99, 0x70, 0xFF, 0x69, 0x6D, 0x52 }; byte[] currentHash = GetHashForBitmap(target); RegisterResultBitmap(target, "PencilOperation_SourceOverTransparentPaint"); Assert.IsTrue(goodHash.SequenceEqual(currentHash), "The hash for the paint operation must match the good hash stored"); }
public void TestFrameClone() { Frame frame1 = FrameGenerator.GenerateRandomFrame(64, 63, 2); Frame frame2 = frame1.Clone(); Assert.AreEqual(frame1, frame2, "Frames cloned using .Clone() should be exactly equivalent"); }
public void TestSequentialFrameListBoundsSharing() { var frames = new List <Frame>(); for (int i = 0; i < 100; i++) { var frame = FrameGenerator.GenerateRandomFrame(32, 32); frame.ID = i; frames.Add(frame); } var map = new DefaultTexturePacker.FrameBoundsMap(); for (int i = 0; i < frames.Count; i++) { var frame = frames[i]; map.RegisterFrames(new[] { frame }, new Rectangle(0, 0, 10, 10 + i)); } var rand = new Random(); // Go around now sharing frames for (int i = 0; i < frames.Count - 1; i++) { map.ShareSheetBoundsForFrames(frames[i], frames[i + 1]); } // Test now frames are all the same var targetRect = new Rectangle(0, 0, 10, 10); foreach (var frame in frames) { Assert.AreEqual(map.GetSheetBoundsForFrame(frame), targetRect); } }
public void TestFrameBoundsSharing() { var frame1 = FrameGenerator.GenerateRandomFrame(32, 32); frame1.ID = 1; var frame2 = FrameGenerator.GenerateRandomFrame(32, 32); frame2.ID = 2; var frame3 = FrameGenerator.GenerateRandomFrame(32, 32); frame3.ID = 3; var bounds1 = new Rectangle(0, 0, 32, 32); var bounds2 = new Rectangle(0, 0, 40, 40); var map = new DefaultTexturePacker.FrameBoundsMap(); map.RegisterFrames(new[] { frame1 }, bounds1); map.RegisterFrames(new[] { frame2 }, bounds2); map.RegisterFrames(new[] { frame3 }, bounds2); Assert.AreEqual(map.GetSheetBoundsForFrame(frame1), bounds1); Assert.AreEqual(map.GetSheetBoundsForFrame(frame2), bounds2); map.ShareSheetBoundsForFrames(frame1, frame2); // frame2 now should point to the same bounds as frame1 Assert.AreEqual(map.GetSheetBoundsForFrame(frame2), bounds1); // Test calling share again with already-shared frames is a noop map.ShareSheetBoundsForFrames(frame1, frame2); Assert.AreEqual(map.GetSheetBoundsForFrame(frame2), bounds1); }
public void TestLongFrameListBoundsSharing() { var frames = new List <Frame>(); for (int i = 0; i < 100; i++) { var frame = FrameGenerator.GenerateRandomFrame(32, 32); frame.ID = i; frames.Add(frame); } var map = new DefaultTexturePacker.FrameBoundsMap(); foreach (var frame in frames) { map.RegisterFrames(new[] { frame }, new Rectangle(0, 0, 10, 10)); } var rand = new Random(); // Go around now sharing frames for (int i = 0; i < frames.Count; i++) { int lower = rand.Next(0, frames.Count); int upper = rand.Next(0, frames.Count); map.ShareSheetBoundsForFrames(frames[lower], frames[upper]); } // Go around now sharing frames map.ShareSheetBoundsForFrames(frames[0], frames[1]); map.ShareSheetBoundsForFrames(frames[10], frames[20]); map.ShareSheetBoundsForFrames(frames[30], frames[5]); }
public void TestFrameBoundsSetForFrame() { var frame1 = FrameGenerator.GenerateRandomFrame(32, 32); frame1.ID = 1; var frame2 = FrameGenerator.GenerateRandomFrame(32, 32); frame2.ID = 2; var rectangle = new Rectangle(0, 0, 32, 32); var newBounds = new Rectangle(32, 0, 32, 32); var map = new DefaultTexturePacker.FrameBoundsMap(); map.RegisterFrames(new[] { frame1 }, rectangle); map.RegisterFrames(new[] { frame2 }, rectangle); // Direct set map.SetSheetBoundsForFrame(frame1, newBounds); Assert.AreEqual(map.GetSheetBoundsForFrame(frame1), newBounds); Assert.AreEqual(map.GetSheetBoundsForFrame(frame2), rectangle); // Now share and set the bounds again map.ShareSheetBoundsForFrames(frame1, frame2); map.SetSheetBoundsForFrame(frame1, newBounds); Assert.AreEqual(map.GetSheetBoundsForFrame(frame2), newBounds); }
public void TestSourceOverAlphaAccumulationOffTransparentOperation() { Bitmap target = FrameGenerator.GenerateRandomBitmap(64, 64, 10); PencilPaintOperation operation = new PencilPaintOperation(target) { Color = Color.FromArgb(127, 0, 0, 0), CompositingMode = CompositingMode.SourceOver }; operation.StartOpertaion(false); operation.MoveTo(5, 5); operation.DrawTo(10, 10); operation.DrawTo(15, 17); operation.DrawTo(20, 25); operation.DrawTo(25, 37); operation.DrawTo(5, 5); operation.FinishOperation(); // Hash of the .png image that represents the target result of the paint operation. Generated through the 'RegisterResultBitmap' method byte[] goodHash = { 0x7E, 0xCD, 0xAB, 0x2D, 0xB, 0x48, 0x83, 0x2B, 0x1E, 0xCA, 0xA, 0x98, 0x68, 0x58, 0x86, 0x66, 0x67, 0x15, 0x62, 0xDA, 0xC4, 0xB5, 0xE2, 0x8, 0x12, 0xBD, 0x3C, 0x7A, 0xF2, 0x92, 0x80, 0x9 }; byte[] currentHash = GetHashForBitmap(target); RegisterResultBitmap(target, "PencilOperation_SourceOverTransparentPaint_AccumulateAlphaOff"); Assert.IsTrue(goodHash.SequenceEqual(currentHash), "The hash for the paint operation must match the good hash stored"); }
private static IEnumerable <Frame> GetRefinedSeeds(IEnumerable <Frame> frames, FrameGenerator info, PIDIV pidiv) { var refined = RefineFrames(frames, info); if (pidiv.Type == PIDType.CuteCharm && info.FrameType != FrameType.MethodH) // only permit cute charm successful frames { return(refined.Where(z => (z.Lead & ~LeadRequired.UsesLevelCall) == LeadRequired.CuteCharm)); } return(refined); }
public void TestFrameCopyFrom() { Animation anim = new Animation("TestAnimation", 16, 16); Frame frame1 = anim.CreateFrame(); Frame frame2 = FrameGenerator.GenerateRandomFrame(16, 16); frame1.CopyFrom(frame2); Assert.AreEqual(frame1, frame2, "After a successful call to CopyFrom(), the frames must return true to .Equals()"); }
// gather possible nature determination seeds until a same-nature PID breaks the unrolling private static IEnumerable <SeedInfo> GetSeeds(PIDIV pidiv, FrameGenerator info, PKM pk) { if (pk.Species == (int)Species.Unown && pk.FRLG) // Gen3 FRLG Unown: reversed await case { return(SeedInfo.GetSeedsUntilUnownForm(pidiv, info, pk.Form)); } if (pidiv.Type == PIDType.CuteCharm && info.FrameType != FrameType.MethodH) // Gen4: ambiguous seed due to gender-buffered PID { return(SeedInfo.GetSeedsUntilNature4Cute(pk)); } return(SeedInfo.GetSeedsUntilNature(pidiv, info)); }
public void TestLayerReinserting() { Frame frame1 = FrameGenerator.GenerateRandomFrame(64, 64, 10); Frame frame2 = frame1.Clone(); IFrameLayer layer = frame2.GetLayerAt(0); frame2.RemoveLayerAt(0, false); frame2.AddLayer(layer, 0); Assert.AreEqual(frame1, frame2, "After removing and readding a layer back to its original place, the frame structure must be considered unchanged"); }
public void TestLayerIndexing() { Frame frame = FrameGenerator.GenerateRandomFrame(64, 64, 5, 1); frame.AddLayer(FrameGenerator.GenerateRandomBitmap(64, 64, 2)); IFrameLayer layer = frame.CreateLayer(); Assert.AreEqual(0, frame.GetLayerAt(0).Index, "Layers fetched with GetLayerAt() must have an index that match the parameter passed"); Assert.AreEqual(1, frame.GetLayerAt(1).Index, "Layers fetched with GetLayerAt() must have an index that match the parameter passed"); Assert.AreEqual(2, frame.GetLayerAt(2).Index, "Layers fetched with GetLayerAt() must have an index that match the parameter passed"); Assert.AreEqual(2, layer.Index, "Layers returned by calls to AddLayer() and CreateLayer() must have an index that match the 'index' parameter passed"); }
void HandleReceivedMessage(RCS_Protocol.RCS_Protocol.PACKET_TYPES type, byte[] data, ConnectionServer.ClientConnection connection, object packetHeader) { try { switch (type) { case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_STATS: { // CreatePacket(PACKET_TYPES type, string data) connection.SendHealthStats(m_AppData.HealthStatistics); } break; case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_CHANNEL_LIST: { FrameGenerator fg = (FrameGenerator)m_AppData.FrameGenerator; string[] list = fg.GetChannelList(); connection.SendChannelList(list); } break; case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_LIVE_VIEW: { RCS_Protocol.RCS_Protocol.LIVE_VIEW_HEADER jpegHeader = (RCS_Protocol.RCS_Protocol.LIVE_VIEW_HEADER)packetHeader; // parse out the requested channel ID from the info string // int channel = Convert.ToInt32(jpegHeader.cameraName); string timeStamp = null; int channelIndex = 0; string lastPlateReading = null; byte[] jpeg = GetCurrentJpeg(jpegHeader.cameraName, out timeStamp, out lastPlateReading, out channelIndex); if (jpeg == null) { jpeg = new byte[10]; // will be treated as null image on receiving end, but keep the state machine going } connection.SendJpeg(jpeg, jpegHeader.cameraName, timeStamp, lastPlateReading); jpeg = null; } break; case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_HOST_NAME: { connection.SendHostName(m_AppData.ThisComputerName); } break; } } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); } }
public void TestFrameCompositing() { Frame frame = FrameGenerator.GenerateRandomFrame(64, 64, 5, 1); Bitmap target = frame.GetComposedBitmap(); // Hash of the .png image that represents the target result of the paint operation. Generated through the 'RegisterResultBitmap' method byte[] goodHash = { 0xB2, 0x91, 0xF2, 0xB1, 0x17, 0xF7, 0x17, 0x46, 0xA0, 0x1C, 0xA4, 0xCB, 0x45, 0x82, 0x17, 0xA4, 0x42, 0x60, 0x2F, 0xEE, 0x7E, 0x1A, 0xDC, 0xE3, 0x2F, 0xB, 0x89, 0xEC, 0x76, 0x6, 0x2C, 0xA1 }; byte[] currentHash = GetHashForBitmap(target); RegisterResultBitmap(target, "FrameCompositing"); Assert.IsTrue(goodHash.SequenceEqual(currentHash), "The hash for the composed frame does not match the good hash stored. Verify the output image for an analysis of what went wrong"); }
public void TestImagesAreIdentical() { // Generate the bitmaps Bitmap bitmap1 = FrameGenerator.GenerateRandomBitmap(64, 64, 10); Bitmap bitmap2 = FrameGenerator.GenerateRandomBitmap(64, 64, 10); // Test the equality Assert.IsTrue(ImageUtilities.ImagesAreIdentical(bitmap1, bitmap2), "ImagesAreIdentical should return true for images that are equal down to each pixel"); // Generate a different random bitmap bitmap2 = FrameGenerator.GenerateRandomBitmap(64, 64, 11); Assert.IsFalse(ImageUtilities.ImagesAreIdentical(bitmap1, bitmap2), "ImagesAreIdentical should return false for images that are not equal down to each pixel"); }
public void TestFrameLayerInsertion() { Frame frame = new Frame(null, 64, 64); Bitmap layer1 = FrameGenerator.GenerateRandomBitmap(64, 64, 10); Bitmap layer2 = FrameGenerator.GenerateRandomBitmap(64, 64, 9); frame.AddLayer(layer1); frame.AddLayer(layer2, 1); Assert.AreEqual(frame, frame.GetLayerAt(0).Frame, "The Frame reference of the layer must match the frame that it was added to"); Assert.AreEqual(3, frame.LayerCount, "The layer count must go up for each new layer added"); Assert.AreEqual(1, frame.GetLayerAt(1).Index, "A layer's index must reflect its current position on the owning frame's layer list"); Assert.IsTrue(ImageUtilities.ImagesAreIdentical(layer2, frame.GetLayerAt(1).LayerBitmap), "The layer bitmaps insertion must obey the index provided on AddLayer"); }
public void TestLayerBitmapUpdating() { // Create a frame Frame frame = new Frame(null, 64, 64); Bitmap layer1 = FrameGenerator.GenerateRandomBitmap(64, 64, 10); frame.CreateLayer(); // Swap the layers frame.SetLayerBitmap(1, layer1); // Test layer swapping by comparing the bitmaps Assert.IsTrue(ImageUtilities.ImagesAreIdentical(layer1, frame.GetLayerAt(1).LayerBitmap), "The layer bitmap has not been updated correctly"); }
void LPREngineProcessLoop() { FRAME frm = null; int channel = 0; FrameGenerator fg = (FrameGenerator)m_AppData.FrameGenerator; int maxChannels = fg.GetNumberOfPhysicalChannels(); DateTime[] timeLastTouched = new DateTime[maxChannels]; TimeSpan timeout = new TimeSpan(0, 0, 0, 5, 0); int loopDelayInMilliSeconds = 1; while (!m_Stop) { frm = null; try { frm = m_LPRProcessQ.Dequeue(); m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.LPR.LPR_ProcessQCnt].HitMe = m_LPRProcessQ.Count; if (frm != null) { // hits here on every frame where motion was detected compared to the previous frame timeLastTouched[frm.SourceChannel] = DateTime.Now; LPRProcessImage(frm); } channel++; if (channel == maxChannels) { channel = 0; } // this forces the plategroup processor to release a group if the car is parked and not moving, only works // if no motion was detected for timeout seconds if (DateTime.Now.Subtract(timeLastTouched[channel]).CompareTo(timeout) > 0) { m_LPRFuntions.PlateGroups_ProcessNewImage(channel, "", 0, 0); // if we have not had a frame to process in a while, force the plate number groupings to expire and report results from last reading } } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); } Thread.Sleep(loopDelayInMilliSeconds); } }
/// <summary> /// Checks a <see cref="PIDIV"/> to see if any encounter frames can generate the spread. Requires further filtering against matched Encounter Slots and generation patterns. /// </summary> /// <param name="pidiv">Matched <see cref="PIDIV"/> containing info and <see cref="PIDIV.OriginSeed"/>.</param> /// <param name="pk"><see cref="PKM"/> object containing various accessible information required for the encounter.</param> /// <returns><see cref="IEnumerable{Frame}"/> to yield possible encounter details for further filtering</returns> public static IEnumerable <Frame> GetFrames(PIDIV pidiv, PKM pk) { if (pk.Version == (int)GameVersion.CXD) { return(Array.Empty <Frame>()); } var info = new FrameGenerator(pk) { Nature = pk.EncryptionConstant % 25 }; var seeds = GetSeeds(pidiv, info, pk); var frames = pidiv.Type == PIDType.CuteCharm ? FilterCuteCharm(seeds, info) : FilterNatureSync(seeds, info); return(GetRefinedSeeds(frames, info, pidiv)); }
public void TestFrameEquals() { Frame fr1 = new Frame(null, 64, 64); Frame fr2 = fr1.Clone(); Assert.AreEqual(fr1, fr2, "The frames after a Clone() operation must be equal"); // Fill both frames with randomly generated images Bitmap bit = FrameGenerator.GenerateRandomBitmap(64, 64, 0); fr1.SetFrameBitmap(bit); fr2.SetFrameBitmap(bit); Assert.AreEqual(fr1, fr2, "Frames with equal images must return true to .Equals()"); fr2.SetFrameBitmap(FrameGenerator.GenerateRandomBitmap(64, 64, 1)); Assert.AreNotEqual(fr1, fr2, "Frames with different images must return false to .Equals()"); }
public void TestFrameLayerCreation() { // TODO: Find out why this test fails under Release mode but succeeds under Debug mode Frame frame = FrameGenerator.GenerateRandomFrame(64, 64, 1, 1); frame.AddLayer(FrameGenerator.GenerateRandomBitmap(64, 64, 2)); frame.AddLayer(FrameGenerator.GenerateRandomBitmap(64, 64, 3)); Bitmap target = frame.GetComposedBitmap(); // Hash of the .png image that represents the target result of the paint operation. Generated through the 'RegisterResultBitmap' method byte[] goodHash = { 0xBF, 0x8F, 0x9B, 0x56, 0xBE, 0x8D, 0xF5, 0xD2, 0x99, 0x1C, 0x9B, 0xEC, 0x56, 0xB8, 0x6D, 0xA9, 0x41, 0xBB, 0x31, 0x66, 0xD, 0xB2, 0xDC, 0x66, 0xF3, 0x5C, 0x9A, 0xDE, 0x59, 0xC2, 0xC2, 0x52 }; byte[] currentHash = GetHashForBitmap(target); RegisterResultBitmap(target, "FrameLayering"); Assert.IsTrue(goodHash.SequenceEqual(currentHash), "The hash for the composed frame does not match the good hash stored. Verify the output image for an analysis of what went wrong"); }
public void TestFrameSharing_LocalBoundsBug() { var frame1 = FrameGenerator.GenerateRandomFrame(32, 32); frame1.ID = 1; var frame2 = FrameGenerator.GenerateRandomFrame(32, 32); frame2.ID = 2; var frame3 = FrameGenerator.GenerateRandomFrame(32, 32); frame3.ID = 3; var bounds1 = new Rectangle(0, 0, 32, 32); var bounds2 = new Rectangle(0, 0, 20, 20); var bounds3 = new Rectangle(0, 0, 10, 10); var map = new DefaultTexturePacker.FrameBoundsMap(); map.RegisterFrames(new [] { frame1 }, bounds1); map.RegisterFrames(new[] { frame2 }, bounds2); map.RegisterFrames(new[] { frame3 }, bounds3); map.ShareSheetBoundsForFrames(frame1, frame2); Assert.AreEqual(map.GetSheetBoundsForFrame(frame3), bounds3); }
public void TestFrameRegistering() { var frame = FrameGenerator.GenerateRandomFrame(32, 32); frame.ID = 1; var bounds = new Rectangle(0, 10, 32, 32); var boundsZero = new Rectangle(0, 0, 32, 32); var map = new DefaultTexturePacker.FrameBoundsMap(); Assert.IsNull(map.GetLocalBoundsForFrame(frame)); Assert.IsFalse(map.ContainsFrame(frame)); map.RegisterFrames(new[] { frame }, bounds); Assert.IsNotNull(map.GetLocalBoundsForFrame(frame)); Assert.IsTrue(map.ContainsFrame(frame)); Assert.AreEqual(map.GetLocalBoundsForFrame(frame), bounds); Assert.AreEqual(map.GetSheetBoundsForFrame(frame), boundsZero, "When adding a frame sheet bounds via RegisterFrames(), the X and Y axis of the bounds rectangle must be ignored and set to 0."); }
public void TestLayerRemoval() { // Create a frame Frame frame = new Frame(null, 64, 64); Bitmap bitmap = FrameGenerator.GenerateRandomBitmap(64, 64, 10); frame.CreateLayer(); // Swap the layers frame.SetLayerBitmap(1, bitmap); IFrameLayer layer = frame.GetLayerAt(0); frame.RemoveLayerAt(0); // Test layer swapping by comparing the bitmaps Assert.AreEqual(null, layer.Frame, "After removing a layer from a frame, its Frame reference must be null"); Assert.IsTrue(ImageUtilities.ImagesAreIdentical(bitmap, frame.GetLayerAt(0).LayerBitmap), "The layer does not appear to have been correctly removed"); }
public void TestFrameBoundsReplacing() { var frame1 = FrameGenerator.GenerateRandomFrame(32, 32); frame1.ID = 1; var frame2 = FrameGenerator.GenerateRandomFrame(32, 32); frame2.ID = 2; var bounds1 = new Rectangle(0, 0, 32, 32); var bounds2 = new Rectangle(32, 32, 40, 40); var map = new DefaultTexturePacker.FrameBoundsMap(); map.RegisterFrames(new[] { frame1 }, bounds1); map.RegisterFrames(new[] { frame2 }, bounds2); var replace1 = new Rectangle(10, 20, 30, 40); var replace2 = new Rectangle(100, 200, 300, 400); map.ReplaceSheetBounds(new [] { replace1, replace2 }); Assert.AreEqual(map.GetSheetBoundsForFrame(frame1), replace1); Assert.AreEqual(map.GetSheetBoundsForFrame(frame2), replace2); }
private static IEnumerable <Frame> RefineFrames3(IEnumerable <Frame> frames, FrameGenerator info) { // ESV // Level // Nature // Current Seed of the frame is the Level Calc (frame before nature) var list = new List <Frame>(); foreach (var f in frames) { bool noLead = !info.AllowLeads && f.Lead != LeadRequired.None; if (noLead) { continue; } var prev = info.RNG.Prev(f.Seed); // ESV var rand = prev >> 16; f.RandESV = rand; f.RandLevel = f.Seed >> 16; f.OriginSeed = info.RNG.Prev(prev); if (f.Lead != LeadRequired.CuteCharm) // needs proc checking { yield return(f); } // Generate frames for other slots after the regular slots if (info.AllowLeads && (f.Lead is LeadRequired.CuteCharm or LeadRequired.None)) { list.Add(f); } } foreach (var f in list) { var leadframes = GenerateLeadSpecificFrames3(f, info); foreach (var frame in leadframes) { yield return(frame); } } }
public void TestRedoOperation_SizedSourceOverAlpha() { // Create the objects Bitmap target = FrameGenerator.GenerateRandomBitmap(64, 64, 10); // Create the test subjects PlottingPaintUndoGenerator generator = new PlottingPaintUndoGenerator(target, "Pencil"); PencilPaintOperation operation = new PencilPaintOperation(target) { Color = Color.FromArgb(127, 0, 0, 0), CompositingMode = CompositingMode.SourceOver, Size = 5, Notifier = generator }; operation.StartOpertaion(); operation.MoveTo(5, 5); operation.DrawTo(10, 10); operation.DrawTo(15, 17); operation.DrawTo(20, 25); operation.DrawTo(25, 37); operation.DrawTo(5, 5); operation.FinishOperation(); byte[] originalHash = GetHashForBitmap(target); // Undo and redo the task back generator.UndoTask.Undo(); generator.UndoTask.Redo(); byte[] afterRedoHash = GetHashForBitmap(target); RegisterResultBitmap(target, "PencilOperation_AfterRedo_SizedSourceOverAlpha"); Assert.IsTrue(originalHash.SequenceEqual(afterRedoHash), "After redoing a paint operation's task, its pixels must return to their original state after the operation was applied"); }
public void TestUndoOperation_SourceOverAlphaFailing() { // Create the objects Bitmap target = FrameGenerator.GenerateRandomBitmap(64, 64, 10); byte[] originalHash = GetHashForBitmap(target); // Create the test subjects PlottingPaintUndoGenerator generator = new PlottingPaintUndoGenerator(target, "Pencil", keepReplacedUndos: false); PencilPaintOperation operation = new PencilPaintOperation(target) { Color = Color.FromArgb(127, 0, 0, 0), CompositingMode = CompositingMode.SourceOver, Notifier = generator }; operation.StartOpertaion(); operation.MoveTo(5, 5); operation.DrawTo(10, 10); operation.DrawTo(15, 17); operation.DrawTo(20, 25); operation.DrawTo(25, 37); operation.DrawTo(5, 5); operation.FinishOperation(); // Undo the task generator.UndoTask.Undo(); byte[] afterUndoHash = GetHashForBitmap(target); RegisterResultBitmap(target, "PencilOperation_AfterUndo_SourceOverAlpha_Failed"); Assert.IsFalse(originalHash.SequenceEqual(afterUndoHash), "Plotting the same pixel repeatedly with an undo generator that has keepReplacedOriginals should fail, since the redrawn pixels have their undo color replaced"); }
public override bool ParseInput() { // passes each of the fields into a function to parse the input // also validates the ranges // min/max frame can be larger in the input box than the limit of a uint but it's low priority to fix that if (!(FormsFunctions.ParseInputD(searchParams.minFrame, out minFrame) && FormsFunctions.ParseInputD(searchParams.maxFrame, out maxFrame) && minFrame <= maxFrame && FormsFunctions.ParseInputD(searchParams.minHour, out minHour) && FormsFunctions.ParseInputD(searchParams.maxHour, out maxHour) && minHour <= maxHour && maxHour <= 23 && FormsFunctions.ParseInputD(searchParams.minMinute, out minMinute) && FormsFunctions.ParseInputD(searchParams.maxMinute, out maxMinute) && minMinute <= maxMinute && maxMinute <= 59)) return false; //parse the id/sid defaulting to 0 FormsFunctions.ParseInputD(searchParams.id, out id); FormsFunctions.ParseInputD(searchParams.sid, out sid); // everything from here on should always be valid input seedDate = searchParams.date.Value; bool shiny = searchParams.isShiny.Checked; bool synch = searchParams.isSynch.Checked; IVFilter ivfilter = searchParams.ivfilters.IVFilter; List<int> encounterSlots = null; if (searchParams.encounterSlot.Text != "Any" && searchParams.encounterSlot.CheckBoxItems.Count > 0) { encounterSlots = new List<int>(); for (int i = 0; i < searchParams.encounterSlot.CheckBoxItems.Count; i++) { if (searchParams.encounterSlot.CheckBoxItems[i].Checked) // We have to subtract 1 because this custom control contains a hidden item for text display encounterSlots.Add(i - 1); } } List<uint> natures = null; if (searchParams.nature.Text != "Any" && searchParams.nature.CheckBoxItems.Count > 0) { natures = (from t in searchParams.nature.CheckBoxItems where t.Checked select (uint) ((Nature) t.ComboBoxItem).Number).ToList(); } frameCompare = new FrameCompare(ivfilter, natures, (int) ((ComboBoxItem) searchParams.ability.SelectedItem).Reference, shiny, synch, false, encounterSlots, (GenderFilter) (searchParams.gender.SelectedItem)); EncounterMod currentMod = synch ? EncounterMod.Synchronize : EncounterMod.None; generator = new FrameGenerator { FrameType = (FrameType) ((ComboBoxItem) searchParams.frameType.SelectedItem).Reference, EncounterMod = currentMod }; if (currentMod == EncounterMod.Synchronize && natures == null) { generator.EncounterMod = EncounterMod.None; } generator.SynchNature = ((Nature) searchParams.synchNature.SelectedItem).Number; generator.EncounterType = EncounterTypeCalc.EncounterString(searchParams.encounterType.Text); return true; }