public static Bitmap Test(int width, int height, String searchText, UrlProvider urlProvider) { System.Random rand = new System.Random(); LayeredComposition c = new LayeredComposition(width, height, rand.Next(1, 9), searchText, urlProvider); c.Compose(); return(c.FinalResult); }
public static Bitmap Test(int width, int height, Bitmap testImage) { LayeredComposition c = new LayeredComposition(width, height); c.subjects.Add(new Subject("http://www.google.com", testImage)); StatusManager.Instance.StatusMessage("Sketching..."); c.CreateSketch(); StatusManager.Instance.StatusMessage("Sketching completed."); return(c.CreateComposition()); }
public bool FetchAndProcessRequest() { bool dreamGenerated = false; try { String result = service.GetOfflineDreamRequest("null"); if ((result.Length > 0) && (!result.Equals("error"))) { // First, split up the result string String[] parameters = result.Split(new String[] { ":@&%^" }, StringSplitOptions.None); if (parameters.Length != 4) { if (EventLog.SourceExists("DreamerService")) { String message = "Incorrect number of parameters " + parameters.Length; EventLog.WriteEntry("DreamerService", message, EventLogEntryType.Error); } return(dreamGenerated); } String phrase = parameters[0]; // Next, grab the total number of subjects int subjects = 3; try { subjects = Int32.Parse(parameters[2]); } catch (Exception) { } // Next, grab the image provider Composition.UrlProvider source = Composition.UrlProvider.Yahoo; if (parameters[3].ToLower().Equals("yahoo")) { source = Composition.UrlProvider.Yahoo; } else if (parameters[3].ToLower().Equals("flickr")) { source = Composition.UrlProvider.Flickr; } else if (parameters[3].ToLower().Equals("mixture")) { source = Composition.UrlProvider.Mixture; } else if (parameters[3].ToLower().Equals("surprise")) { source = Composition.UrlProvider.SurpriseMe; } // Finally, instantiate the correct composition class Composition c = null; try { /* * if (parameters[1].ToLower().Equals("structured")) * { * c = new SimpleComposition(compositionWidth, compositionHeight, subjects, phrase, source); * } * else if (parameters[1].ToLower().Equals("chaos")) * { * c = new RandomComposition(compositionWidth, compositionHeight, subjects, phrase, source); * } * else if (parameters[1].ToLower().Equals("segmented")) * { * c = new WaveletTransformComposition(compositionWidth, compositionHeight, subjects, phrase, source); * } * else if (parameters[1].ToLower().Equals("surprise")) * { * int value = randomEngine.Next(1, 4); * if (value == 1) * { * c = new SimpleComposition(compositionWidth, compositionHeight, subjects, phrase, source); * } * else if (value == 2) * { * c = new WaveletTransformComposition(compositionWidth, compositionHeight, subjects, phrase, source); * } * else * { * c = new RandomComposition(compositionWidth, compositionHeight, subjects, phrase, source); * } * } */ c = new LayeredComposition(compositionWidth, compositionHeight, subjects, phrase, source); // Generate the dream if (c != null) { // Finally, handle the request. ProcessRequest(c); dreamGenerated = true; } } catch (Exception ex) { if (EventLog.SourceExists("DreamerService")) { String message = "Unknown error: " + ex.ToString(); EventLog.WriteEntry("DreamerService", message, EventLogEntryType.Error); } } finally { if (c != null) { c.Dispose(); } } } } catch (Exception ex) { if (EventLog.SourceExists("DreamerService")) { String message = "Unknown error: " + ex.ToString(); EventLog.WriteEntry("DreamerService", message, EventLogEntryType.Error); } } return(dreamGenerated); }