public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); instruction = (Instructions)Enum.Parse(typeof(Instructions), treeNode.ChildNodes[0].FindTokenAndGetText()); AddChild("firstOperand", treeNode.ChildNodes[1]); AddChild("secondOperand", treeNode.ChildNodes[2]); }
public HandlerContext(Instructions block, TryInstructionHandler ilHandler, TryContext tryContext, TBBHandler tbbHandler) : base(block) { ILHandler = ilHandler; TryContext = tryContext; TBBHandler = tbbHandler; }
public void InstarctionsJoinTest() { var incomeInstruction = new Instructions { Alpha = 25, Blur = .5 }; var defInstructions = new Instructions { Alpha = 50, BorderColor = "red" }; var mandatoryInstructions = new Instructions { Contrast = 25, Blur = .8 }; incomeInstruction.Join(defInstructions); Assert.AreEqual(25,incomeInstruction.Alpha); Assert.AreEqual(.5, incomeInstruction.Blur); Assert.AreEqual("red", incomeInstruction.BorderColor); incomeInstruction.Join(mandatoryInstructions,true); Assert.AreEqual(25, incomeInstruction.Alpha); Assert.AreEqual(.8, incomeInstruction.Blur); Assert.AreEqual("red", incomeInstruction.BorderColor); Assert.AreEqual(25, incomeInstruction.Contrast); }
public void Visit(Instructions.Shift instruction) { // Check register ValidateRegister(instruction.Register); // Check opcode switch (instruction.Type) { case Instructions.ShiftType.Sla: case Instructions.ShiftType.Rl: case Instructions.ShiftType.Slx: case Instructions.ShiftType.Sl0: case Instructions.ShiftType.Sl1: case Instructions.ShiftType.Sra: case Instructions.ShiftType.Srx: case Instructions.ShiftType.Rr: case Instructions.ShiftType.Sr0: case Instructions.ShiftType.Sr1: // OK break; default: AddErrorWithLine("(Internal Error) Instruction has invalid ShiftType"); return; } }
public void Resize(string source, string destination, int height) { try { using (var sourceStream = _diskProvider.OpenReadStream(source)) { using (var outputStream = _diskProvider.OpenWriteStream(destination)) { var settings = new Instructions(); settings.Height = height; var job = new ImageJob(sourceStream, outputStream, settings); ImageBuilder.Current.Build(job); } } } catch { if (_diskProvider.FileExists(destination)) { _diskProvider.DeleteFile(destination); } throw; } }
public WaypointInstruction(Instructions instr, double value) { value.AssertNotNegative(); this.Instruction = instr; this.Value = value; }
public ImageJob(object source, object dest, Instructions instructions) { this.RequestedInfo = new List<string>(); this.ResultInfo = new Dictionary<string, object>(); this.Source = source; this.Dest = dest; this.Instructions = instructions; }
public ImageStorageService(IFileStorageService storageService, Instructions defaultInstructions, Instructions mandatoryInstructions, Instructions defaultThumbnailInstructions, Instructions mandatoryThumbnailInstructions, string paramsPrefix = "thmb-") { this.storageService = storageService; this.defaultInstructions = defaultInstructions; this.mandatoryInstructions = mandatoryInstructions; this.defaultThumbnailInstructions = defaultThumbnailInstructions; this.mandatoryThumbnailInstructions = mandatoryThumbnailInstructions; this.paramsPrefix = paramsPrefix; }
private static byte[] ProcessImage(byte[] image, Instructions instructions) { using (var outputImage = new MemoryStream()) { using (var inputImage = new MemoryStream(image)) { var job = new ImageJob(inputImage, outputImage, instructions); job.Build(); return outputImage.ToArray(); } } }
protected void Page_Load(object sender, EventArgs e) { string[] images = new string[] { "/private/m.jpg","tulip-leaf.jpg", "sample.tif", "Sun_256.png", "red-leaf.jpg", "quality-original.jpg", "fountain-small.jpg", "Sun_256.png" }; string[] cropModes = new string[] { "width=500;height=200&mode=max", "crop=300,300,800,500" }; var dict = new string[]{ "format=png","lossless=true", "format=png","lossless=true;noalpha=true", "quality=100","quality=100", "quality=90","quality=78", "quality=80","quality=65", "quality=70","quality=55", "quality=50","quality=40", "quality=40","quality=30", "quality=20","quality=10", "quality=10","quality=3", "quality=5","quality=0" }; StringBuilder sb = new StringBuilder(); foreach (string img in images) { foreach (string cropMode in cropModes) { for (int i = 0; i < dict.Length; i += 2) { string a = dict[i]; string b = dict[i + 1]; var ia = new Instructions(cropMode + ";" + a); var ib = new Instructions(cropMode + ";" + b); if (string.IsNullOrEmpty(ia.Format)) ia.Format = "jpg"; ib.Format = "webp"; if (ib.JpegQuality != null) { ib["noalpha"] = "true"; ib["bgcolor"] = "white"; } sb.Append("<tr><td>"); sb.Append("<h6>" + a + "</h6>"); sb.Append("<img src=\"" + img + ia.ToQueryString() + "\" /><br/>"); ia["showbytes"] = "true"; sb.Append("<img src=\"" + img + ia.ToQueryString() + "\" />"); sb.Append("</td><td>"); sb.Append("<h6>" + b + "</h6>"); sb.Append("<img src=\"" + img + ib.ToQueryString() + "\" /><br/>"); ib["showbytes"] = "true"; sb.Append("<img src=\"" + img + ib.ToQueryString() + "\" />"); sb.Append("</td></tr>\n"); } } } lit.Text = sb.ToString(); }
public static void Join(this Instructions instructions, Instructions join, bool overwrite = false) { foreach (var key in join.AllKeys) { var hasKey = instructions.AllKeys.Any(k => k == key); if (overwrite && hasKey) { instructions.Remove(key); instructions.Add(key, join[key]); } else if (!hasKey) { instructions.Add(key, join[key]); } } }
public ActionResult ImagesUpload(HttpPostedFileBase[] files, string sessionKey, int? defaultImageIndex) { ProductSessionObject sObject = (ProductSessionObject)Session[sessionKey]; string thumbsPath = ProductImage.DefaultThumbDirectory, imagesPath = ProductImage.DefaultImageDirectory; //If images were uploaded and there were no default image selected, //then the first one is our default. if (files.Count() > 0 && !defaultImageIndex.HasValue) { defaultImageIndex = 0; } //Defines the image resizing and format settings for thumbnails Instructions thumbResizeSettings = new Instructions() { Width = 300, Height = 400, Mode = FitMode.Pad }; foreach (var item in files) { string extension = Path.GetExtension(item.FileName).ToLower(); if (extension == ".png" || extension == ".jpg" || extension == ".jpeg") { ProductImage image = new ProductImage(); //First we resize/save the thmbnail. //ImageResizer can generate the filename using variables like these <guid> and <ext> below. //I guess their working is obvious, so I won't explain. ImageResizer.ImageJob thumbImageJob = new ImageResizer.ImageJob(item, string.Format("{0}<guid>.<ext>", thumbsPath), thumbResizeSettings); thumbImageJob.Build(); //Setting the filename for the full image and for its thumbnail image.Filename = Path.GetFileName(thumbImageJob.FinalPath); image.ThumbFilename = image.Filename; //Finally, save the full image with the same name as the thumbnail item.SaveAs(Server.MapPath(imagesPath + image.Filename)); //Adds the newly uploaded image object do the Session Object. NOT to database. sObject.Images.Add(image); } } ViewBag.defaultImageIndex = defaultImageIndex; return PartialView(sObject.Images); }
private static double GetRandomInstructionValue(Instructions instructions) { var value = 0; var random = new Random(); switch (instructions) { case Instructions.None: value = 0; break; case Instructions.SetSpeed: case Instructions.SpeedUpPercent: case Instructions.SlowDownPercent: value = random.Next(MinWayPointValue, MaxWayPointValue); break; } return value; }
public static void SaveImage(Stream source, int width, int height, string path, FitMode mode, bool dispose = true, bool resetSource = false) { var instructions = new Instructions { Width = width, Height = height, Mode = mode, Encoder = "freeimage", OutputFormat = OutputFormat.Jpeg }; var job = new ImageJob { Instructions = instructions, Source = source, Dest = path, CreateParentDirectory = true, ResetSourceStream = resetSource, DisposeSourceObject = dispose, AddFileExtension = !Path.HasExtension(path) }; ImageBuilder.Current.Build(job); }
public void doConverting(string inputdir, string outputdir, Instructions instr) { if (!File.Exists(inputdir)) { doErrorMessage(3); } Stopwatch sw = Stopwatch.StartNew(); Console.WriteLine("Starting conversion of " + inputdir); string input_content = File.ReadAllText(inputdir); string output_content = ""; switch (instr) { case Instructions.Encode: output_content = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(input_content)); break; case Instructions.Decode: output_content = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(input_content)); break; case Instructions.NotSure: break; default: break; } Console.WriteLine("Conversion done."); Console.WriteLine("Writing to file..."); File.WriteAllText(outputdir, output_content); Console.WriteLine("Conversion ended in " + (sw.ElapsedMilliseconds+5) + "ms"); sw.Stop(); }
public void Pushi() { Instructions.Pushi(_cpu, 101); Assert.That(Sp, Is.EqualTo(4)); Assert.That(_cpu.Peek(), Is.EqualTo(101)); }
void CustomInitialize() { Instructions.Add(new DelegateInstruction(() => mHasInstructionBeenExecuted = true)); this.Set("HasSetBeenExecuted").To(true).After(0); }
public void Incri() { Instructions.Incr(_cpu, Register.A); Assert.That(A, Is.EqualTo(1)); }
public void Movi() { Instructions.Movi(_cpu, Register.A, 1000); Assert.That(A, Is.EqualTo(1000)); }
/// <summary> /// Gets the details of a gallery. /// </summary> /// <param name="folderName">The name of the folder which contains the gallery.</param> /// <returns>The details of the specified gallery.</returns> public ViewGalleryVM GetGallery(string folderName) { // Input validation: the folder name must be specified. if (String.IsNullOrEmpty(folderName)) { throw new ArgumentNullException("folderName"); } // Input validation: the folder name must not contain any invalid character. if (folderName.IndexOfAny(Path.GetInvalidPathChars()) > -1 || folderName.IndexOfAny(Path.GetInvalidFileNameChars()) > -1) { throw new ArgumentException("The folder name contains invalid characters!", "folderName"); } // Get the application relative virtual path of the gallery folder (eg. ~/Photos/First). string folderVirtualPath = Path.Combine(this.ConfigService.StorageFolderVirtualPath, folderName); // Get the full physical path of the gallery folder (eg. C:\inetpub\wwwroot\Photos\First). string folderPhysicalPath = HttpContext.Current.Server.MapPath(folderVirtualPath); // Integrity check: the folder must exist. if (!Directory.Exists(folderPhysicalPath)) { throw new ArgumentException("The specified folder does not exist!", "folderName"); } // Integrity check: the requested folder must be the direct child of the storage folder. string storagePhysicalPath = HttpContext.Current.Server.MapPath(this.ConfigService.StorageFolderVirtualPath); string folderParentPhysicalPath = Directory.GetParent(folderPhysicalPath).FullName; if (!folderParentPhysicalPath.Equals(storagePhysicalPath, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentOutOfRangeException("folderName", "Invalid folder name!"); } // Get the names of the image files in the requested folder. IEnumerable <string> imageFileNames = this.GetImageFiles(folderPhysicalPath); List <ViewGalleryImageVM> images = new List <ViewGalleryImageVM>(); // Ensure that all image has thumbnails. foreach (string imageFileName in imageFileNames) { string thumbnailFileName = "th_" + imageFileName; string thumbnailPhysicalPath = Path.Combine(folderPhysicalPath, thumbnailFileName); // Create the thumbnail if it does not exist. if (!File.Exists(thumbnailPhysicalPath)) { string imagePhysicalPath = Path.Combine(folderPhysicalPath, imageFileName); if (ConfigService.AutoGenerateThumbnails) { Instructions instructions = new Instructions { Width = 80, Height = 60, Mode = FitMode.Max }; ImageJob job = new ImageJob(imagePhysicalPath, thumbnailPhysicalPath, instructions); try { job.Build(); } catch { // In case of any error, use the original image as the thumbnail without resizing it. thumbnailFileName = imageFileName; } } else { thumbnailFileName = imageFileName; } } images.Add(new ViewGalleryImageVM { ThumbnailUrl = Path.Combine(folderVirtualPath, thumbnailFileName), ImageUrl = Path.Combine(folderVirtualPath, imageFileName) }); } // Build the returned model. ViewGalleryVM model = new ViewGalleryVM { Title = folderName, Images = images }; return(model); }
/// <summary> /// Gets the list of the available galleries. /// </summary> /// <returns>The list of galleries.</returns> public ViewGalleriesVM GetGalleries() { ViewGalleriesVM model = new ViewGalleriesVM { Galleries = new List <ViewGallerySummaryVM>() }; // Get the full physical path of the folder which contains the galleries (eg. C:\inetpub\wwwroot\Photos). string storageFolderPhysicalPath = HttpContext.Current.Server.MapPath(this.ConfigService.StorageFolderVirtualPath); // Get the full physical paths of each galleries (eg. list of C:\inetpub\wwwroot\Photos\First, C:\inetpub\wwwroot\Photos\Second etc.). IOrderedEnumerable <string> folderPhysicalPaths = Directory.GetDirectories(storageFolderPhysicalPath).OrderByDescending(p => p); // Enumerate the galleries. foreach (string folderPhysicalPath in folderPhysicalPaths) { // Get the names of the image files in the requested folder. IEnumerable <string> imageFileNames = this.GetImageFiles(folderPhysicalPath); // Get the number of images in the requested folder. int imageCount = imageFileNames.Count(); // If there is at least one image in the gallery. if (imageCount > 0) { // Get the name of the gallery folder (eg. First). string folderName = Path.GetFileName(folderPhysicalPath); // Get the full physical path of the gallery thumbnail image (eg. C:\inetpub\wwwroot\First\folder.jpg). string thumbnailPhysicalPath = Path.Combine(folderPhysicalPath, "folder.jpg"); // If the thumbnail file does not exist, create it by resizing the first image and saving as "folder.jpg". if (!File.Exists(thumbnailPhysicalPath)) { string firstImagePhysicalPath = Path.Combine(folderPhysicalPath, imageFileNames.First()); if (ConfigService.AutoGenerateThumbnails) { Instructions instructions = new Instructions { Width = 80, Height = 60, Mode = FitMode.Max }; ImageJob job = new ImageJob(firstImagePhysicalPath, thumbnailPhysicalPath, instructions); try { job.Build(); } catch { // In case of any error, use the first image as the thumbnail without resizing it. thumbnailPhysicalPath = firstImagePhysicalPath; } } else { thumbnailPhysicalPath = firstImagePhysicalPath; } } // Get the file name of the thumbnail (eg. folder.jpg or img1.jpg). string thumbnailFileName = Path.GetFileName(thumbnailPhysicalPath); // Get the application relative virtual path of the gallery thumbnail image (eg. ~/Photos/First/img1.jpg); string thumbnailVirtualPath = Path.Combine(Path.Combine(this.ConfigService.StorageFolderVirtualPath, folderName), thumbnailFileName); // Build the returned model item for the gallery. ViewGallerySummaryVM gallery = new ViewGallerySummaryVM { FolderName = folderName, Count = imageCount, ThumbnailUrl = thumbnailVirtualPath }; model.Galleries.Add(gallery); } } return(model); }
public string[] OutlineFunctionBody(ref MasterNodeDataCollector dataCollector, bool instanced, bool isShadowCaster, string shaderName, string[] billboardInfo, ref TessellationOpHelper tessOpHelper, string target) { List <string> body = new List <string>(); for (int i = 0; i < OutlineBodyBegin.Length; i++) { body.Add(OutlineBodyBegin[i]); } if (tessOpHelper.EnableTesselation) { body.Add("#include \"" + TessellationOpHelper.TessInclude + "\""); body.Add("#pragma target " + target); } else { body.Add("#pragma target 3.0"); } bool customOutline = dataCollector.UsingCustomOutlineColor || dataCollector.UsingCustomOutlineWidth; int outlineMode = customOutline ? m_offsetMode : (m_mode == OutlineMode.VertexOffset ? 0 : 1); string surfConfig = string.Format(OutlineSurfaceConfig, (customOutline ? m_customNoFog : m_noFog) ? "nofog " : string.Empty); if (tessOpHelper.EnableTesselation) { tessOpHelper.WriteToOptionalParams(ref surfConfig); } body.Add(surfConfig); if (instanced) { body.Add(OutlineInstancedHeader); } if (customOutline) { if (isShadowCaster) { for (int i = 0; i < InputList.Count; i++) { dataCollector.AddToInput(InputList[i].NodeId, InputList[i].PropertyName, true); } } else { if (!string.IsNullOrEmpty(m_inputs)) { body.Add(m_inputs.Trim('\t', '\n')); } } if (!DirtyInput && !isShadowCaster) { body.Add(OutlineBodyStructDefault); } if (!isShadowCaster) { body.Add(OutlineBodyStructEnd); } } else if (!isShadowCaster) { body.Add(OutlineBodyStructBegin); body.Add(OutlineBodyStructDefault); body.Add(OutlineBodyStructEnd); } if (instanced) { for (int i = 0; i < OutlineBodyInstancedBegin.Length; i++) { body.Add((i == 0) ? string.Format(OutlineBodyInstancedBegin[i], shaderName) : OutlineBodyInstancedBegin[i]); } if ((object)billboardInfo != null) { for (int j = 0; j < billboardInfo.Length; j++) { body.Add(string.Format(BillboardInstructionFormat, billboardInfo[j])); } } switch (outlineMode) { case 0: body.Add(string.Format(OutlineVertexOffsetMode, WidthVariableAccessInstanced)); break; case 1: body.Add(string.Format(OutlineVertexScaleMode, WidthVariableAccessInstanced)); break; case 2: body.Add(string.Format(OutlineVertexCustomMode, WidthVariableAccessInstanced)); break; } for (int i = 0; i < OutlineBodyInstancedEnd.Length; i++) { body.Add(OutlineBodyInstancedEnd[i]); } } else { if (customOutline) { if (isShadowCaster) { for (int i = 0; i < UniformList.Count; i++) { dataCollector.AddToUniforms(UniformList[i].NodeId, UniformList[i].PropertyName); } } else { if (!string.IsNullOrEmpty(Uniforms)) { body.Add(Uniforms.Trim('\t', '\n')); } } } if (!dataCollector.UsingCustomOutlineColor) { body.Add(OutlineDefaultUniformColor); } if (!dataCollector.UsingCustomOutlineWidth) { body.Add(OutlineDefaultUniformWidth); } //Functions if (customOutline) { body.Add(Functions); } if (tessOpHelper.EnableTesselation && !isShadowCaster) { body.Add(tessOpHelper.Uniforms().TrimStart('\t')); body.Add(tessOpHelper.GetCurrentTessellationFunction.Trim('\t', '\n') + "\n"); } if (tessOpHelper.EnableTesselation) { body.Add(OutlineTessVertexHeader); } else { body.Add(OutlineDefaultVertexHeader); body.Add(OutlineDefaultVertexOutputDeclaration); } if (customOutline) { if (!string.IsNullOrEmpty(VertexData)) { body.Add("\t" + VertexData.Trim('\t', '\n')); } } if ((object)billboardInfo != null) { for (int j = 0; j < billboardInfo.Length; j++) { body.Add(string.Format(BillboardInstructionFormat, billboardInfo[j])); } } switch (outlineMode) { case 0: body.Add(string.Format(OutlineVertexOffsetMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName)); break; case 1: body.Add(string.Format(OutlineVertexScaleMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName)); break; case 2: body.Add(string.Format(OutlineVertexCustomMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName)); break; } for (int i = 0; i < OutlineBodyDefaultSurfBegin.Length; i++) { body.Add(OutlineBodyDefaultSurfBegin[i]); } if (dataCollector.UsingCustomOutlineColor) { body.Add("\t" + Instructions.Trim('\t', '\n')); } else { for (int i = 0; i < OutlineSurfBody.Length; i++) { body.Add(OutlineSurfBody[i]); } } for (int i = 0; i < OutlineBodyDefaultSurfEnd.Length; i++) { body.Add(OutlineBodyDefaultSurfEnd[i]); } } string[] bodyArr = body.ToArray(); body.Clear(); body = null; return(bodyArr); }
public Instruction() { op = Instructions.ERR_INSTRUCTION; src = new LocationInfo(); dst = new LocationInfo(); }
public void EnforceMaxSize(ref Stream stream, MediaFile file, MediaSettings mediaSettings) { if (!mediaSettings.EnforceMaxImageSize) { return; } var outputStream = new MemoryStream(); var instructions = new Instructions {JpegQuality = mediaSettings.ResizeQuality}; instructions["maxwidth"] = mediaSettings.MaxImageSizeWidth.ToString(); instructions["maxheight"] = mediaSettings.MaxImageSizeHeight.ToString(); instructions["autorotate"] = "true"; ImageBuilder.Current.Build(new ImageJob(stream, outputStream, instructions)); Stream originalStream = stream; stream = outputStream; originalStream.Dispose(); }
void Tree_DayUpdate() { // Erase code related to tree spreading. var spread = FindCode( // if ((int)growthStage >= 5 OpCodes.Ldarg_0, Instructions.Ldfld(typeof(Tree), nameof(Tree.growthStage)), OpCodes.Call, OpCodes.Ldc_I4_5, OpCodes.Blt, // && environment is Farm ... OpCodes.Ldarg_1, Instructions.Isinst(typeof(Farm)), OpCodes.Brfalse ); spread.Extend( // hasSeed.Value = false; OpCodes.Ldarg_0, Instructions.Ldfld(typeof(Tree), nameof(Tree.hasSeed)), OpCodes.Ldc_I4_0, OpCodes.Callvirt ); spread.length -= 4; spread.Prepend( // if (!tapped && config.OnlyPreventTapped) Instructions.Ldarg_0(), Instructions.Ldfld(typeof(Tree), nameof(Tree.tapped)), Instructions.Call_get(typeof(NetBool), nameof(NetBool.Value)), Instructions.Brtrue(AttachLabel(spread.End[0])), Instructions.Call(GetType(), nameof(isOnlyPreventTapped)), Instructions.Brfalse(AttachLabel(spread.End[0])) ); spread.ReplaceJump(6, spread[0]); // if RetainSeed: Don't remove seeds when on the farm var remove_seed = spread.End; remove_seed.length += 4; // if (!config.RetainSeed || !environment is Farm) var lbl = generator.DefineLabel(); remove_seed.Prepend( Instructions.Call(GetType(), nameof(isRetainSeed)), Instructions.Brfalse(lbl), Instructions.Ldarg_1(), Instructions.Isinst(typeof(Farm)), Instructions.Brtrue(AttachLabel(remove_seed.End[0])) ); remove_seed.ReplaceJump(5, remove_seed[0]); remove_seed[5].labels.Add(lbl); // Increase chance that tree has a seed. // float num3 = 0.05f; var seed = remove_seed.FindNext( Instructions.Ldc_R4(0.05f), OpCodes.Stloc_1 ); seed[0] = Instructions.Call(GetType(), nameof(getSeedChance)); }
/// <summary> /// Resizes and processes the specified source image and stores the encoded result in the specified destination. /// If passed a source Stream, Bitmap, or Image instance, it will be disposed after use. Use disposeSource=False to disable that behavior. /// </summary> /// <param name="source">May be an instance of string (a physical path or app-relative virtual path), VirtualFile, IVirtualBitmapFile, HttpPostedFile, Bitmap, Image, or Stream. App-relative virtual paths will use the VirtualPathProvider system</param> /// <param name="dest">May be a physical path (string), or a Stream instance. Does not have to be seekable.</param> /// <param name="instructions">Resizing and processing command to apply to the image.</param> public virtual ImageJob Build(object source, object dest, Instructions instructions) { var j = new ImageJob(source, dest, instructions, true, false); Build(j); return j; }
/// <summary> /// Gets the final size of an image /// </summary> /// <returns></returns> public virtual Size GetFinalSize(Size originalSize, Instructions q) { ImageState s = new ImageState(new ResizeSettings(q), originalSize, true); Process(s); return s.finalSize; }
public void Visit(Instructions.OutputConstant instruction) { parent.LastInstruction = 0x2B000 | instruction.Constant << 4 | instruction.Port; }
public virtual bool Equals(Instructions other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other, this); }
public void Visit(Instructions.JumpCallIndirect instruction) { int opcode = instruction.IsCall ? 0x24000 : 0x26000; parent.LastInstruction = opcode | instruction.Register1 << 8 | instruction.Register2 << 4; }
public void Visit(Instructions.HwBuild instruction) { parent.LastInstruction = 0x14080 | instruction.Register << 8; }
public void Visit(Instructions.JumpCall instruction) { int opcode = ReadOpcodeTable(MiscOpcodes, instruction.IsCall ? 1 : 2); opcode += ReadOpcodeTable(ConditionalOffset, (int) instruction.Condition); parent.LastInstruction = opcode | (ushort) instruction.Destination; }
public void Visit(Instructions.SetRegisterBank instruction) { if (!instruction.AlternateBank) parent.LastInstruction = 0x37000; else parent.LastInstruction = 0x37001; }
public void Visit(Instructions.SetInterruptFlag instruction) { int opcodeIndex = instruction.EnableInterrupts ? 6 : 5; parent.LastInstruction = ReadOpcodeTable(MiscOpcodes, opcodeIndex); }
public void Visit(Instructions.ReturnInterrupt instruction) { int opcodeIndex = instruction.EnableInterrupts ? 4 : 3; parent.LastInstruction = ReadOpcodeTable(MiscOpcodes, opcodeIndex); }
public void Visit(Instructions.Return instruction) { parent.LastInstruction = ReadOpcodeTable(MiscOpcodes, 0) + ReadOpcodeTable(ConditionalOffset, (int) instruction.Condition); }
public void Visit(Instructions.Shift instruction) { // Or opcode with register, shift left and or with shift type parent.LastInstruction = ShiftOpcode[parent.processorNumber] | instruction.Register << 8 | (int) instruction.Type; }
private static async Task<string> ResizeImage(Stream streamInput, CloudBlockBlob blobOutput, ImageSize size) { streamInput.Position = 0; using (var memoryStream = new MemoryStream()) { // use a memory stream, since using the blob stream directly causes InvalidOperationException due to the way image resizer works var instructions = new Instructions(imageDimensionsTable[size]); var job = new ImageJob(streamInput, memoryStream, instructions, disposeSource: false, addFileExtension: false); // use the advanced version of resize so that we can get the content type var result = ImageBuilder.Current.Build(job); memoryStream.Position = 0; await blobOutput.UploadFromStreamAsync(memoryStream); var contentType = result.ResultMimeType; blobOutput.Properties.ContentType = contentType; blobOutput.SetProperties(); return contentType; } }