public async Task <ActionResult> DeleteConfirmed(int id) { FaceSize faceSize = await db.FaceSize.FindAsync(id); db.FaceSize.Remove(faceSize); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "FaceSizeID,Size")] FaceSize faceSize) { if (ModelState.IsValid) { db.Entry(faceSize).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(faceSize)); }
public async Task <ActionResult> Create([Bind(Include = "FaceSizeID,Size")] FaceSize faceSize) { if (ModelState.IsValid) { db.FaceSize.Add(faceSize); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(faceSize)); }
// GET: FaceSizes/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FaceSize faceSize = await db.FaceSize.FindAsync(id); if (faceSize == null) { return(HttpNotFound()); } return(View(faceSize)); }
void LoadRenderTarget(TextureTarget target, string fileName) { if (string.IsNullOrEmpty(fileName)) { throw new InvalidOperationException(string.Format( "A valid image file path was not specified for texture \"{0}:{1}\".", Name, target)); } var image = CV.LoadImage(fileName, ColorType); if (image == null) { throw new InvalidOperationException(string.Format( "Failed to load texture target \"{0}:{1}\" from the specified path: \"{2}\".", Name, target, fileName)); } var faceSize = FaceSize.GetValueOrDefault(); if (faceSize > 0 && (image.Width != faceSize || image.Height != faceSize)) { var resized = new IplImage(new Size(faceSize, faceSize), image.Depth, image.Channels); CV.Resize(image, resized); image = resized; } var flipMode = FlipMode; if (flipMode.HasValue) { CV.Flip(image, null, flipMode.Value); } var internalFormat = faceSize > 0 ? (PixelInternalFormat?)null : InternalFormat; TextureHelper.UpdateTexture(target, internalFormat, image); }
public override Texture CreateResource(ResourceManager resourceManager) { var texture = new Texture(); GL.BindTexture(TextureTarget.TextureCubeMap, texture.Id); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)MinFilter); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (int)MagFilter); var faceSize = FaceSize.GetValueOrDefault(); if (faceSize > 0) { GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapNegativeX, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapPositiveY, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapNegativeY, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapPositiveZ, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapNegativeZ, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); } GL.BindTexture(TextureTarget.TextureCubeMap, 0); return(texture); }
public override IObservable <Texture> Process <TSource>(IObservable <TSource> source) { return(Observable.Defer(() => { var fbo = 0; var faceSize = 0; var depthRenderbuffer = 0; var colorTarget = default(Texture); var textureTargetBase = TextureTarget.TextureCubeMapPositiveX; var textureIndex = 0; return source.CombineEither( ShaderManager.WindowSource.Do(window => { window.Update(() => { colorTarget = new Texture(); GL.BindTexture(TextureTarget.TextureCubeMap, colorTarget.Id); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)MinFilter); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (int)MagFilter); faceSize = FaceSize.GetValueOrDefault(Math.Max(window.Width, window.Height)); GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapNegativeX, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapPositiveY, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapNegativeY, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapPositiveZ, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.TextureCubeMapNegativeZ, 0, InternalFormat, faceSize, faceSize, 0, PixelFormat.Bgr, PixelType.UnsignedByte, IntPtr.Zero); GL.GenFramebuffers(1, out fbo); GL.GenRenderbuffers(1, out depthRenderbuffer); GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, depthRenderbuffer); GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferStorage.DepthComponent, faceSize, faceSize); GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, depthRenderbuffer); GL.BindTexture(TextureTarget.TextureCubeMap, 0); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0); GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); }); }), (input, window) => { foreach (var state in renderState) { state.Execute(window); } var clearMask = ClearMask; var textureTarget = textureIndex + textureTargetBase; GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, textureTarget, colorTarget.Id, 0); window.UpdateViewport(faceSize, faceSize); window.UpdateScissor(faceSize, faceSize); if (clearMask != ClearBufferMask.None) { GL.ClearColor(ClearColor); GL.Clear(clearMask); } foreach (var shader in window.Shaders) { shader.Dispatch(); } window.UpdateViewport(); window.UpdateScissor(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); textureIndex = (textureIndex + 1) % 6; return colorTarget; }).Where(texture => textureIndex == 0).Finally(() => { if (fbo > 0) { GL.DeleteFramebuffers(1, ref fbo); GL.DeleteRenderbuffers(1, ref depthRenderbuffer); colorTarget.Dispose(); } }); })); }
/// <summary> /// 将指定的用户头像调整到指定尺寸,并返回相应的URL /// </summary> /// <param name="faceURL">要调整的用户头像URL</param> /// <param name="size">设置要调整到的尺寸</param> /// <returns>返回调整后的头像URL</returns> public static string OffsetFace(string faceURL, FaceSize size) { if (!General.IsNullable(faceURL)) { int offset = faceURL.LastIndexOf("/"); if (offset != -1) return faceURL.Substring(0, offset) + (int)size; } return null; }