public Bitmap(int width, int height, Imaging.PixelFormat format) { switch (format) { case PixelFormat.Alpha: case PixelFormat.Canonical: case PixelFormat.DontCare: case PixelFormat.Extended: case PixelFormat.Format16bppArgb1555: case PixelFormat.Format16bppGrayScale: case PixelFormat.Format16bppRgb555: case PixelFormat.Format16bppRgb565: case PixelFormat.Format1bppIndexed: case PixelFormat.Format24bppRgb: case PixelFormat.Format32bppArgb: case PixelFormat.Format32bppPArgb: case PixelFormat.Format32bppRgb: case PixelFormat.Format48bppRgb: case PixelFormat.Format4bppIndexed: case PixelFormat.Format64bppArgb: case PixelFormat.Format64bppPArgb: case PixelFormat.Format8bppIndexed: case PixelFormat.Gdi: case PixelFormat.Indexed: case PixelFormat.Max: case PixelFormat.PAlpha: case PixelFormat.Undefined: ABitmap = Android.Graphics.Bitmap.CreateBitmap(width, height, Android.Graphics.Bitmap.Config.Argb8888); break; } //throw new NotImplementedException(); }
public ShaderResourceView GetResource(Imaging.ImageFile source) { var key = source.Path; ShaderResourceView res; if (_Resources.TryGetValue(key, out res)) return res; res = new ShaderResourceView(_Engine.Device, GetTexture(source)); _Resources.Add(key, res); return res; }
public void Size() { var file = Environment.CurrentDirectory + @"\icon.png"; var bytes = File.ReadAllBytes(file); var i = new Imaging(); var size = i.Size(bytes); Assert.IsNotNull(size); var bitMap = new Bitmap(file); Assert.AreEqual(bitMap.Width, size.Width); Assert.AreEqual(bitMap.Height, size.Height); }
public unsafe Texture2D GetTexture(Imaging.ImageFile source) { var key = source.Path; Texture2D tex; if (_Textures.TryGetValue(key, out tex)) return tex; byte[] buffer; var desc = new Texture2DDescription { ArraySize = 1, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Height = source.Height, Width = source.Width, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Immutable }; if (source.Format == Imaging.ImageFormat.A16R16G16B16Float) { buffer = source.GetData(); desc.Format = SharpDX.DXGI.Format.R16G16B16A16_Float; } else { buffer = Imaging.ImageConverter.GetA8R8G8B8(source); for (var i = 0; i < buffer.Length; i += 4) { var r = buffer[i + 0]; var b = buffer[i + 2]; buffer[i + 0] = b; buffer[i + 2] = r; } desc.Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm; if (source.Format == Imaging.ImageFormat.A8R8G8B8_Cube) desc.ArraySize = 6; } fixed (byte* p = buffer) { var ptr = (IntPtr)p; var pitch = SharpDX.DXGI.FormatHelper.SizeOfInBytes(desc.Format) * source.Width; var dataRects = new DataRectangle[desc.ArraySize]; for (var i = 0; i < desc.ArraySize; ++i) dataRects[i] = new DataRectangle(ptr + i * pitch * source.Height, pitch); tex = new Texture2D(_Engine.Device, desc, dataRects); } _Textures.Add(key, tex); return tex; }
public override void Draw(Imaging.VirtualCanvas canvas) { if (!Dirty) return; if (Clicked) { canvas.DrawButton( Area.X, Area.Y, Area.Width, Area.Height, FontInfo.ID, FontInfo.Height, BorderColor, FillColorClicked, FontColorClicked, Text); } else { canvas.DrawButton( Area.X, Area.Y, Area.Width, Area.Height, FontInfo.ID, FontInfo.Height, BorderColor, FillColor, FontColor, Text); } Dirty = false; }
/// <summary> /// Create a BitmapSource from an array of pixels. /// </summary> /// <param name="pixelWidth">Width of the Bitmap</param> /// <param name="pixelHeight">Height of the Bitmap</param> /// <param name="dpiX">Horizontal DPI of the Bitmap</param> /// <param name="dpiY">Vertical DPI of the Bitmap</param> /// <param name="pixelFormat">Format of the Bitmap</param> /// <param name="palette">Palette of the Bitmap</param> /// <param name="pixels">Array of pixels</param> /// <param name="stride">stride</param> public static BitmapSource Create( int pixelWidth, int pixelHeight, double dpiX, double dpiY, PixelFormat pixelFormat, Imaging.BitmapPalette palette, System.Array pixels, int stride ) { return new CachedBitmap( pixelWidth, pixelHeight, dpiX, dpiY, pixelFormat, palette, pixels, stride); }
void Calculate(Imaging.IImageFilter filter, bool normalization) { double r = filter.GetRadius(); ReallocLut(r); int i; int pivot = Diameter << (ImgSubPixConst.SHIFT - 1); for (i = 0; i < pivot; i++) { double x = (double)i / (double)ImgSubPixConst.SCALE; double y = filter.CalculateWeight(x); m_weight_array[pivot + i] = m_weight_array[pivot - i] = AggBasics.iround(y * ImgFilterConst.SCALE); } int end = (Diameter << ImgSubPixConst.SHIFT) - 1; m_weight_array[0] = m_weight_array[end]; if (normalization) { Normalize(); } }
private void closebtn_MouseLeave(object sender, MouseEventArgs e) { closebtn.Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.닫기.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
/// <summary> /// Gets the song /// </summary> #if OFFLINE_IMPLEMENTED public static async Task PlaySpecifiedSong(System.Windows.Shapes.Rectangle backgroundRect, MediaElement mediaElement, string musicLink, int index, string songTitle, Label songLabel, ChromiumWebBrowser youtubePlayer) { songLabel.Content = "Now Playing: " + songTitle; MusicPanel.IsPlaying = true; MusicPanel.SetIndex(index); if (GetMusic.IsConverting) { GetMusic.FFMpeg.Stop(); } //songLabel.Content = "Loading..."; Console.WriteLine("Music links: " + musicLink + " " + VideoId); //TODO: test for possible issue var fullSavePath = await GetMusicVideo(musicLink, youtubePlayer); ///<summary>Set the background</summary> var fileName = SongThumb.GetSongThumb( QueryVideo.SongSearchListResponse.Items[MusicPanel.GetIndex()].Snippet.Thumbnails.High.Url, Path.GetFileNameWithoutExtension(fullSavePath)); var image = System.Drawing.Image.FromFile(fileName); var blur = new GaussianBlur(image as Bitmap); var blurredThumb = blur.Process(50); image.Dispose(); var hBitmap = blurredThumb.GetHbitmap(); var backgroundImageBrush = new ImageBrush(); backgroundImageBrush.ImageSource = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); DeleteObject(hBitmap); blurredThumb.Dispose(); backgroundImageBrush.Stretch = Stretch.UniformToFill; backgroundRect.Fill = backgroundImageBrush; backgroundRect.Effect = null; mediaElement.Opacity = 100; var saveName = Path.GetFileName(fullSavePath); Console.WriteLine("Save name variable in PlaySpecifiedSong method " + saveName); try { var mp4SaveName = saveName.Replace(".webm", ".mp4"); fullSavePath = Path.Combine(FilePaths.SaveLocation(), mp4SaveName); //Console.WriteLine(fullSavePath); if (saveName.Contains(".webm") && !File.Exists(fullSavePath)) { songLabel.Content = "Converting..."; await GetMusic.ConvertWebmToMp4(Path.Combine(FilePaths.SaveLocation(), saveName), mp4SaveName); mediaElement.Source = new Uri(fullSavePath); } else { mediaElement.Source = new Uri(fullSavePath); } } catch (NullReferenceException nullReferenceException) { Console.WriteLine("Some how fullSavePath was not a file path..."); } Console.WriteLine(mediaElement.Source.ToString()); ///<summary>Renable this when coding in the offline mode</summary> /// //mediaElement.Play(); }
public void UnlockBits(Imaging.BitmapData bitmapdata) { throw new NotImplementedException(); }
protected override void Execute() { base.Execute(); //s3-eu-west-1.amazonaws.com/chaosdata/hobit.mp4 OperationProgress = 0.1; var sourceS3Settings = GetS3Settings(SourceFilePath); OperationProgress = 0.2; var destinationS3Settings = GetS3Settings(DestinationFilePath); OperationProgress = 0.3; TempSourceFilepath = Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(DestinationFilePath)); OperationProgress = 0.4; TempDestinationFilepath = Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(DestinationFilePath)); OperationProgress = 0.5; using (var s3 = AWSClientFactory.CreateAmazonS3Client(AwsAccessKey, AwsSecretKey, GetRegion(sourceS3Settings.Region))) { OperationProgress = 0.6; var request = new Amazon.S3.Model.GetObjectRequest { BucketName = sourceS3Settings.BucketName, Key = sourceS3Settings.Key }; OperationProgress = 0.7; using (var stream = s3.GetObject(request).ResponseStream) using (var file = new FileStream(TempSourceFilepath, FileMode.Create)) { OperationProgress = 0.8; stream.CopyTo(file); } OperationProgress = 0.9; } using (var imaging = new Imaging(TempSourceFilepath)) { imaging.Resize(Width, Height, FillTypes.scale, Quality, TempDestinationFilepath); } OperationProgress = 0.9; using (var s3 = AWSClientFactory.CreateAmazonS3Client(AwsAccessKey, AwsSecretKey, GetRegion(destinationS3Settings.Region))) { OperationProgress = 0.10; var request = new Amazon.S3.Model.PutObjectRequest { BucketName = destinationS3Settings.BucketName, Key = destinationS3Settings.Key, FilePath = TempDestinationFilepath, AutoCloseStream = true, Timeout = 30 * 60 * 60, CannedACL = S3CannedACL.PublicRead }; OperationProgress = 0.11; s3.PutObject(request); } }
public void ResizeDataNull() { var i = new Imaging(); i.Resize(null, new ImageVersion()); }
public void GetNegativeQuality() { var expected = new GifFormat(); var i = new Imaging(); foreach (var extension in expected.FileExtensions) { var format = i.Get(extension, -45); Assert.AreEqual(Imaging.DefaultImageQuality, format.Quality); } }
public void CreateMenu() { this.context_menu = new ContextMenu(); this.state_item = new SparkleMenuItem() { Header = Controller.StateText, IsEnabled = false }; Image folder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"), Width = 16, Height = 16 }; SparkleMenuItem folder_item = new SparkleMenuItem() { Header = "SparkleShare", Icon = folder_image }; SparkleMenuItem add_item = new SparkleMenuItem() { Header = "Add hosted project…" }; this.log_item = new SparkleMenuItem() { Header = "Recent changes…", IsEnabled = Controller.RecentEventsItemEnabled }; CheckBox notify_check_box = new CheckBox() { Margin = new Thickness(6, 0, 0, 0), IsChecked = (Controller.Folders.Length > 0 && Program.Controller.NotificationsEnabled) }; SparkleMenuItem notify_item = new SparkleMenuItem() { Header = "Notifications" }; notify_item.Icon = notify_check_box; SparkleMenuItem about_item = new SparkleMenuItem() { Header = "About SparkleShare" }; this.exit_item = new SparkleMenuItem() { Header = "Exit" }; add_item.Click += delegate { Controller.AddHostedProjectClicked(); }; this.log_item.Click += delegate { Controller.RecentEventsClicked(); }; about_item.Click += delegate { Controller.AboutClicked(); }; notify_check_box.Click += delegate { this.context_menu.IsOpen = false; Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; notify_item.Click += delegate { Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; this.exit_item.Click += delegate { this.notify_icon.Dispose(); Controller.QuitClicked(); }; this.context_menu.Items.Add(this.state_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(folder_item); if (Controller.Folders.Length > 0) { int i = 0; foreach (string folder_name in Controller.Folders) { SparkleMenuItem subfolder_item = new SparkleMenuItem() { Header = folder_name.Replace("_", "__") }; Image subfolder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("folder"), Width = 16, Height = 16 }; if (!string.IsNullOrEmpty(Controller.FolderErrors [i])) { subfolder_item.Icon = new Image() { Source = (BitmapSource)Imaging.CreateBitmapSourceFromHIcon( System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16)) }; SparkleMenuItem error_item = new SparkleMenuItem() { Header = Controller.FolderErrors [i], IsEnabled = false }; SparkleMenuItem try_again_item = new SparkleMenuItem() { Header = "Try again" }; try_again_item.Click += delegate { Controller.TryAgainDelegate(folder_name); }; subfolder_item.Items.Add(error_item); subfolder_item.Items.Add(new Separator()); subfolder_item.Items.Add(try_again_item); } else { subfolder_item.Icon = subfolder_image; subfolder_item.Click += delegate { Controller.OpenFolderDelegate(folder_name); }; } this.context_menu.Items.Add(subfolder_item); i++; } } folder_item.Items.Add(this.log_item); folder_item.Items.Add(add_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(notify_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(about_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(this.exit_item); this.notify_icon.ContextMenu = this.context_menu; }
public void TakeFlats() { //Pulls flat requests from the flat stack (file) and services accordingly LogEvent lg = new LogEvent(); SessionControl openSession = new SessionControl(); lg.LogIt("Checking for flat requests"); //Opt out if no flats to look at if (!HaveFlatsToDo()) { lg.LogIt("No flats to do"); return; } else { lg.LogIt("Have flats do: Starting Flats"); } //Fire off flatman if enabled, otherwise point the telescope up for dawn or dusk flats // Sort flats by filter and source (i.e. twightlight or dawn) if (openSession.IsFlatManEnabled) { //Stage the mount to the flatman FlatMan flmn = new FlatMan(); lg.LogIt("Staging FlatMan"); bool stgResult = flmn.FlatManStage(); if (!stgResult) { lg.LogIt("FlatMan Staging Failed -- aborting flats"); return; } //If Manual Setup is selected, then pause for user to position the FlatMan for flats // Disconnect imaging devices before attaching panel, then reconnect afterwards // this keeps the SBIG driver from freaking out when the guider USB is hot swapped // with the FlatMan USB (Build 182+) if (openSession.IsFlatManManualSetupEnabled) { lg.LogIt("Pausing to attach FlatMan panel"); lg.LogIt("Disconnecting imaging devices"); TSXLink.Connection.DisconnectDevice(TSXLink.Connection.Devices.Camera); TSXLink.Connection.DisconnectDevice(TSXLink.Connection.Devices.Guider); TSXLink.Connection.DisconnectDevice(TSXLink.Connection.Devices.Focuser); TSXLink.Connection.DisconnectDevice(TSXLink.Connection.Devices.Rotator); MessageBox.Show("Attach the FlatMan, then press OK"); lg.LogIt("Connecting imaging devices"); TSXLink.Connection.ConnectDevice(TSXLink.Connection.Devices.Camera); TSXLink.Connection.ConnectDevice(TSXLink.Connection.Devices.Guider); TSXLink.Connection.ConnectDevice(TSXLink.Connection.Devices.Focuser); TSXLink.Connection.ConnectDevice(TSXLink.Connection.Devices.Rotator); } //Turn on Flatman panel, if it hasn't been done already lg.LogIt("Lighting up FlatMan panel"); flmn.Light = true; } else //Dusk or dawn flats { //Unpark mount, if parked, which it often is to do dusk flats TSXLink.Mount.UnPark(); //point telescope essentially up lg.LogIt("Pointing telescope just west of zenith"); TSXLink.Mount.SlewAzAlt(200.0, (60), "Flat Spot"); //Turn tracking off TSXLink.Mount.TurnTrackingOff(); } //Alright, all ready to go. //Loop on the flat entries in the flat stack file, if any while (HaveFlatsToDo()) { switch (openSession.FlatLightSource) { case (LightSource.lsNone): { break; } case (LightSource.lsFlatMan): { if (openSession.IsFlatManEnabled) { // ********************** Use Flatman //Rotate to PA, if there is a rotator is enabled Flat iFlat = GetLeastRotatedFlat(); if (openSession.IsRotationEnabled) { Rotator.RotateToRotatorPA(iFlat.RotationPA); } Imaging nhi = new Imaging(); nhi.DoFlatManFlats(iFlat.TargetName, iFlat.RotationPA, iFlat.SideOfPier, iFlat.FlatFilter); RemoveFlat(iFlat); //remove flat from flat stack file } break; } case (LightSource.lsDusk): { // ******************** Use Dusk Flat iFlat = GetLowestIndexFlat(); Imaging nhi = new Imaging(); nhi.DoTwilightFlats(iFlat, true); RemoveFlat(iFlat); //remove flat from flat stack file break; } case (LightSource.lsDawn): { // ******************** Use Dawn Flat iFlat = GetHighestIndexFlat(); Imaging nhi = new Imaging(); nhi.DoTwilightFlats(iFlat, false); RemoveFlat(iFlat); //remove flat from flat stack file break; } default: break; } } //If FlatMan was used, then shut it down if (openSession.IsFlatManEnabled) { //Turn off flatman functions FlatMan flmn = new FlatMan(); lg.LogIt("Terminating FlatMan"); //Turn on Flatman panel, if it hasn't been done already lg.LogIt("Turning off FlatMan panel"); flmn.Light = false; //If Manual Setup is selected, then pause for user to position the FlatMan for flats if (openSession.IsFlatManManualSetupEnabled) { lg.LogIt("Pausing to detach FlatMan panel"); MessageBox.Show("Detach the FlatMan, then press OK"); } } //Turn tracking on TSXLink.Mount.TurnTrackingOn(); //Park the mount TSXLink.Mount.Park(); return; }
private void LoadPDFAndLookForAttachments(string PDFPath) { try { pd.close(); } catch { // pd isn't open } FileDropStatus.Text = ""; AttachmentsPanel.Children.Clear(); if (!String.Equals(System.IO.Path.GetExtension(PDFPath), ".pdf", StringComparison.CurrentCultureIgnoreCase)) { MessageBoxResult result = MessageBox.Show("PDF Attacher only reads PDFs.", "PDF expected."); } else { FileDropStatus.Text = System.IO.Path.GetFileName(PDFPath); pd = PDDocument.load(PDFPath); // Get attachments and save out as a file PDDocumentCatalog catalog = pd.getDocumentCatalog(); PDDocumentNameDictionary names = catalog.getNames(); PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles(); Map embeddedFileNames = embeddedFiles.getNames(); embeddedFileNamesNet = embeddedFileNames.ToDictionary <String, PDComplexFileSpecification>(); AttachmentsPanel.Children.Clear(); //For-Each Loop is used to list all embedded files (if there is more than one) foreach (KeyValuePair <String, PDComplexFileSpecification> entry in embeddedFileNamesNet) { StackPanel attachmentPanel = new StackPanel(); attachmentPanel.Orientation = Orientation.Vertical; attachmentPanel.Margin = new Thickness(5); attachmentPanel.MinWidth = 90; System.Windows.Controls.Image attachmentImage = new System.Windows.Controls.Image(); attachmentImage.Height = 32; attachmentImage.Width = 32; attachmentPanel.Tag = entry.Key; attachmentPanel.MouseEnter += AttachmentPanel_MouseEnter; attachmentPanel.MouseLeave += AttachmentPanel_MouseLeave; attachmentPanel.MouseUp += AttachmentPanel_MouseUp; Icon attachmentIcon = ShellIcon.GetLargeIconFromExtension(System.IO.Path.GetExtension(entry.Key)); BitmapSource attachmentBitmapSource = Imaging.CreateBitmapSourceFromHIcon(attachmentIcon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); attachmentImage.Source = attachmentBitmapSource; attachmentImage.Margin = new Thickness(5, 5, 5, 0); attachmentIcon.Dispose(); TextBlock attachmentTextBlock = new TextBlock(); attachmentTextBlock.Margin = new Thickness(5); attachmentTextBlock.Text = System.IO.Path.GetFileName(entry.Key); System.Windows.Controls.Image deleteImage = new System.Windows.Controls.Image(); deleteImage.Height = 20; deleteImage.Width = 20; deleteImage.Margin = new Thickness(0, 6, -50, -6); // var uriSource = new Uri(@"/PDFBox_sharp;component/DeleteIcon.png", UriKind.Relative); // deleteImage.Source = new BitmapImage(uriSource); // attachmentPanel.Children.Add(deleteImage); attachmentPanel.Children.Add(attachmentImage); attachmentPanel.Children.Add(attachmentTextBlock); AttachmentsPanel.Children.Add(attachmentPanel); } Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(PDFPath); BitmapSource bmpSrc = Imaging.CreateBitmapSourceFromHIcon(sysicon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); PDFIcon.Source = bmpSrc; sysicon.Dispose(); } //pd.close(); }
BitmapSource BitmapSourceFromIcon(Icon icon) => Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
/// <summary> /// Method written for playlists /// </summary> /// <param name="backgroundRect"></param> /// <param name="musicLink"></param> /// <param name="songTitle"></param> /// <param name="songLabel"></param> /// <param name="youtubePlayer"></param> /// <param name="backgroundImageUrl"></param> /// <returns></returns> public static async Task <bool> PlaySpecifiedSong(Rectangle backgroundRect, string musicLink, string songTitle, TextBlock songLabel, ChromiumWebBrowser youtubePlayer, string backgroundImageUrl, Button playButton) { songLabel.Text = "Loading..."; int maxTries = 4; int count = 0; while (true) { try { var songName = await GetMusicVideo(musicLink, youtubePlayer); MusicPanel.IsPlaying = true; songLabel.Text = "Now Playing: " + songTitle; var pauseUri = new Uri("Icons/Stop.png", UriKind.Relative); var streamInfo = Application.GetResourceStream(pauseUri); var temp = BitmapFrame.Create(streamInfo.Stream); playButton.Background = new ImageBrush(temp); //Set the background var fileName = Music.GetSongThumb( backgroundImageUrl, RemoveIllegalPathCharacters(songName)); var image = Image.FromFile(fileName); var blur = new GaussianBlur(image as Bitmap); Bitmap blurredThumb = null; try { blurredThumb = blur.Process(15); } catch { blurredThumb = blur.Process(15); } image.Dispose(); var hBitmap = blurredThumb.GetHbitmap(); var backgroundImageBrush = new ImageBrush(); backgroundImageBrush.ImageSource = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); DeleteObject(hBitmap); blurredThumb.Dispose(); backgroundImageBrush.Stretch = Stretch.UniformToFill; backgroundRect.Fill = backgroundImageBrush; backgroundRect.Effect = null; streamInfo.Stream.Close(); streamInfo.Stream.Dispose(); return(true); } catch (Exception e) { Console.WriteLine(e); count++; if (count == maxTries) { return(false); } } } }
public static async Task <bool> PlaySpecifiedSong(Rectangle backgroundRect, string musicLink, int index, string songTitle, TextBlock songLabel, ChromiumWebBrowser youtubePlayer, Button playButton) { songLabel.Text = "Loading..."; int maxTries = 4; int count = 0; while (true) { try { MusicPanel.Index = index; var songName = await GetMusicVideo(musicLink, youtubePlayer); MusicPanel.IsPlaying = true; songLabel.Text = "Now Playing: " + songTitle; var pauseUri = new Uri("Icons/Stop.png", UriKind.Relative); var streamInfo = Application.GetResourceStream(pauseUri); var temp = BitmapFrame.Create(streamInfo.Stream); playButton.Background = new ImageBrush(temp); string fileName; //Set the background if (MusicPanel.PlayingSongs) { fileName = GetSongThumb( QueryYoutube.SongSearchListResponse.Items[MusicPanel.Index].Snippet.Thumbnails.High.Url, RemoveIllegalPathCharacters(songName)); } else { fileName = GetSongThumb( QueryYoutube.SongSearchListResponse.Items[MusicPanel.Index].Snippet.Thumbnails.High.Url, RemoveIllegalPathCharacters(songName)); } var image = Image.FromFile(fileName); var blur = new GaussianBlur(image as Bitmap); Bitmap blurredThumb = null; try { blurredThumb = blur.Process(15); } catch { blurredThumb = blur.Process(15); } image.Dispose(); var hBitmap = blurredThumb.GetHbitmap(); var backgroundImageBrush = new ImageBrush(); backgroundImageBrush.ImageSource = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); DeleteObject(hBitmap); blurredThumb.Dispose(); backgroundImageBrush.Stretch = Stretch.UniformToFill; backgroundRect.Fill = backgroundImageBrush; backgroundRect.Effect = null; streamInfo.Stream.Close(); streamInfo.Stream.Dispose(); GC.Collect(); return(true); } catch (Exception e) { Console.WriteLine(e); count++; if (count == maxTries) { return(false); } } } /* var saveName = Path.GetFileName(fullSavePath); * Console.WriteLine("Save name variable in PlaySpecifiedSong method " + saveName); * try * { * var mp4SaveName = saveName.Replace(".webm", ".mp4"); * * fullSavePath = Path.Combine(FilePaths.SaveLocation(), mp4SaveName); * } * catch (NullReferenceException nullReferenceException) * { * Console.WriteLine("Some how fullSavePath was not a file path..."); * }*/ }
public ImageFilterLookUpTable(Imaging.IImageFilter filter, bool normalization) { m_weight_array = new int[256]; Calculate(filter, normalization); }
public void GetInvalid() { var i = new Imaging(); var format = i.Get(Guid.NewGuid().ToString()); Assert.IsNotNull(format as JpegFormat); }
private void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPtr buffer, int width, int height, Image image, ref Size currentSize, ref MemoryMappedFile mappedFile, ref MemoryMappedViewAccessor viewAccessor) { if (image.Dispatcher.HasShutdownStarted) { return; } var createNewBitmap = false; lock (lockObject) { int pixels = width * height; int numberOfBytes = pixels * BytesPerPixel; createNewBitmap = mappedFile == null || currentSize.Height != height || currentSize.Width != width; if (createNewBitmap) { //If the MemoryMappedFile is smaller than we need then create a larger one //If it's larger then we need then rather than going through the costly expense of //allocating a new one we'll just use the old one and only access the number of bytes we require. if (viewAccessor == null || viewAccessor.Capacity < numberOfBytes) { ReleaseMemoryMappedView(ref mappedFile, ref viewAccessor); mappedFile = MemoryMappedFile.CreateNew(null, numberOfBytes, MemoryMappedFileAccess.ReadWrite); viewAccessor = mappedFile.CreateViewAccessor(); } currentSize.Height = height; currentSize.Width = width; } //TODO: Performance analysis to determine which is the fastest memory copy function //NativeMethodWrapper.CopyMemoryUsingHandle(viewAccessor.SafeMemoryMappedViewHandle.DangerousGetHandle(), buffer, numberOfBytes); CopyMemory(viewAccessor.SafeMemoryMappedViewHandle.DangerousGetHandle(), buffer, (uint)numberOfBytes); //Take a reference to the backBufferHandle, once we're on the UI thread we need to check if it's still valid var backBufferHandle = mappedFile.SafeMemoryMappedFileHandle; image.Dispatcher.BeginInvoke((Action)(() => { lock (lockObject) { if (backBufferHandle.IsClosed || backBufferHandle.IsInvalid) { return; } if (createNewBitmap) { if (image.Source != null) { image.Source = null; GC.Collect(1); } var stride = width * BytesPerPixel; var bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(backBufferHandle.DangerousGetHandle(), width, height, PixelFormat, stride, 0); image.Source = bitmap; } else { if (image.Source != null) { var sourceRect = new Int32Rect(dirtyRect.X, dirtyRect.Y, dirtyRect.Width, dirtyRect.Height); var bitmap = (InteropBitmap)image.Source; bitmap.Invalidate(sourceRect); } } } }), dispatcherPriority); } }
public void SizeDataEmpty() { var i = new Imaging(); i.Size(new byte[0]); }
private ImageSource ProcessRectangeImageSourceForBitmap(Bitmap bmp) { BitmapData bitmapData = bmp.LockBits(new Rectangle((bmp.Width / 2) - (FilterWidth / 2), (bmp.Height / 2) - (FilterHeight / 2), FilterWidth, FilterHeight), ImageLockMode.ReadWrite, bmp.PixelFormat); EuclideanColorFiltering filter = new EuclideanColorFiltering(new RGB(byte.Parse(redTextBox.Text), byte.Parse(greenTextBox.Text), byte.Parse(blueTextBox.Text)), short.Parse(radiusTextBox.Text)); filter.ApplyInPlace(bitmapData); if (StartDetecting) { BlobCounter blobCounter = new BlobCounter(); blobCounter.FilterBlobs = true; blobCounter.MinHeight = 2; blobCounter.MinWidth = 2; blobCounter.MaxHeight = bitmapData.Height - 1; blobCounter.MaxWidth = bitmapData.Width - 1; blobCounter.ProcessImage(bitmapData); bmp.UnlockBits(bitmapData); Blob[] blobs = blobCounter.GetObjectsInformation(); SimpleShapeChecker shapeChecker = new SimpleShapeChecker(); Graphics g = Graphics.FromImage(bmp); System.Drawing.Pen yellowPen = new System.Drawing.Pen(System.Drawing.Color.Yellow, 5); foreach (var corner in Corners) { g.DrawRectangle(yellowPen, corner.X + (bmp.Width / 2) - (FilterWidth / 2), corner.Y + (bmp.Height / 2) - (FilterHeight / 2), 1, 1); } for (int i = 0, n = blobs.Length; i < n; i++) { List <IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]); List <IntPoint> corners; if (shapeChecker.IsConvexPolygon(edgePoints, out corners)) { if (calibrated) { if (Corners.Count < MAX_CORNERS) { foreach (var corner in corners) { if (!Corners.Contains(corner)) { Corners.Add(corner); } } } else { testPassedLabel.Content = "Light was detected"; } } } } } var handle = bmp.GetHbitmap(); try { return(Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); } finally { DeleteObject(handle); } }
public void ResizeVersionNull() { var i = new Imaging(); i.Resize(new byte[123], null); }
private ImageSource ProcessImageSourceForBitmap(Bitmap bmp) { BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); EuclideanColorFiltering filter = new EuclideanColorFiltering(); filter.CenterColor = new RGB(byte.Parse(redTextBox.Text), byte.Parse(greenTextBox.Text), byte.Parse(blueTextBox.Text)); filter.Radius = short.Parse(radiusTextBox.Text); filter.ApplyInPlace(bitmapData); BlobCounter blobCounter = new BlobCounter(); blobCounter.FilterBlobs = true; blobCounter.MinHeight = 15; blobCounter.MinWidth = 15; blobCounter.MaxHeight = bitmapData.Width - 1; blobCounter.MaxWidth = bitmapData.Width - 1; blobCounter.ProcessImage(bitmapData); Blob[] blobs = blobCounter.GetObjectsInformation(); bmp.UnlockBits(bitmapData); SimpleShapeChecker shapeChecker = new SimpleShapeChecker(); Graphics g = Graphics.FromImage(bmp); System.Drawing.Pen redPen = new System.Drawing.Pen(System.Drawing.Color.Red, 5); System.Drawing.Pen yellowPen = new System.Drawing.Pen(System.Drawing.Color.Yellow, 5); System.Drawing.Pen greenPen = new System.Drawing.Pen(System.Drawing.Color.Green, 5); System.Drawing.Pen bluePen = new System.Drawing.Pen(System.Drawing.Color.Blue, 5); for (int i = 0, n = blobs.Length; i < n; i++) { List <IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]); AForge.Point center; float radius; if (shapeChecker.IsCircle(edgePoints, out center, out radius)) { g.DrawEllipse(yellowPen, (float)(center.X - radius), (float)(center.Y - radius), (float)(radius * 2), (float)(radius * 2)); } else { List <IntPoint> corners; if (shapeChecker.IsQuadrilateral(edgePoints, out corners)) { if (shapeChecker.CheckPolygonSubType(corners) == PolygonSubType.Rectangle) { g.DrawPolygon(greenPen, ToPointsArray(corners)); } else { g.DrawPolygon(bluePen, ToPointsArray(corners)); } } else { corners = PointsCloud.FindQuadrilateralCorners(edgePoints); g.DrawPolygon(redPen, ToPointsArray(corners)); } } } redPen.Dispose(); greenPen.Dispose(); bluePen.Dispose(); yellowPen.Dispose(); g.Dispose(); var handle = bmp.GetHbitmap(); try { return(Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); } finally { DeleteObject(handle); } }
public void SaveAdd(Imaging.EncoderParameters encoderParams) { throw new NotImplementedException(); }
static void Main(string[] args) { { CsvFileReaderWriter reader = new CsvFileReaderWriter(); List <string> directories = FTP.GetDirectory(Constants.FTP.BaseUrl); List <Student> students = new List <Student>(); foreach (var directory in directories) { Student student = new Student() { AbsoluteUrl = Constants.FTP.BaseUrl }; student.FromDirectory(directory); Student.counter++; Console.WriteLine("Position " + students.Count); Console.WriteLine(student); string infoFilePath = student.FullPathUrl + "/" + Constants.Locations.InfoFile; bool fileExists = FTP.FileExists(infoFilePath); if (fileExists == true) { Console.WriteLine("Found info file:"); var infoFileBytes = FTP.DownloadFileBytes(infoFilePath); //Convert from infoFileBytes incoming bytes to string string asciiString = Encoding.ASCII.GetString(infoFileBytes, 0, infoFileBytes.Length); var csvFile = reader.ParseString(asciiString); //var entries = reader.GetEntities(csvFile); if (csvFile.Count.Equals(2)) { student.FromCSV(csvFile[1]); //if (student.StudentId.Equals(Constants.myrecord.StudentId)) //{ // student.MyRecord = true; //} if (student.Age >= 15 && student.Age < 100) { Console.WriteLine("The student age is " + student.Age); } else { Console.WriteLine("Invalid age detected"); } } else { Console.WriteLine("Bad CSV data detected"); } } else { Console.WriteLine("Could not find info file:"); } Console.WriteLine("\t" + infoFilePath); string imageFilePath = student.FullPathUrl + "/" + Constants.Locations.ImageFile; bool imageFileExists = FTP.FileExists(imageFilePath); if (imageFileExists == true) { Console.WriteLine("Found image file:"); var imageBytes = FTP.DownloadFileBytes(imageFilePath); Image image = Imaging.byteArrayToImage(imageBytes); //student.ImageData = Imaging.ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Jpeg); } else { Console.WriteLine("Could not find image file:"); } Console.WriteLine("\t" + imageFilePath); students.Add(student); } Student me = students.SingleOrDefault(x => x.StudentId.Equals(Constants.myrecord.StudentId)); me.MyRecord = true; var avgage = students.Average(x => x.Age); var minage = students.Min(x => x.Age); var maxage = students.Max(x => x.Age); Console.WriteLine("Thera are a total of " + students.Count + " records."); Console.WriteLine("The students age average is " + avgage); Console.WriteLine("The older student is " + maxage + " years"); Console.WriteLine("The younger student is " + minage + " years"); foreach (var student in students) { Console.WriteLine(student.ToString()); //Console.WriteLine(student.ToCSV()); } using (var file = File.CreateText($@"{Constants.Locations.ContentFolder}" + "\\Records.csv")) { file.WriteLine("StudentId,FirstName,LastName,DateOfBirth,MyRecord,ImageData"); foreach (var student in students) { file.WriteLine(string.Join(",", student.ToCSV())); } } using (var file = File.CreateText($@"{Constants.Locations.ContentFolder}" + "\\Records.xml")) { foreach (var student in students) { file.WriteLine(string.Join(",", student.ToXML())); } } using (var file = File.CreateText($@"{Constants.Locations.ContentFolder}" + "\\Records.json")) { foreach (var student in students) { file.WriteLine(string.Join(",", student.ToJSON())); } } UploadFolder(Constants.Locations.ContentFolder, Constants.FTP.BaseUrl); } }
public bool AddImaging(Imaging imaging) { try { entities.Imagings.Add(imaging); entities.SaveChanges(); return true; } catch (Exception x) { FileLogger.LogError(x); return false; } }
public About() { InitializeComponent(); this.Loaded += About_Loaded; this.PageAbout_Image_Icon.Source = Imaging.CreateBitmapSourceFromHBitmap(KcptunGUI.Resource.图片.png_72x72_user_1.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
private void minibtn_MouseEnter(object sender, MouseEventArgs e) { minibtn.Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.최소_on.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
public MessageBoxDialogWindow(string title, string message, string checkBoxLabel, string buttonTrueLabel, string buttonFalseLabel, bool defaultChoice, Icons icon) { InitializeComponent(); if (title != null) { this.Title = title; } if (message != null) { this.textBlock.Inlines.Add(message); } if (checkBoxLabel != null) { this.checkBox.Visibility = Visibility.Visible; this.checkBox.Content = checkBoxLabel; } if (buttonTrueLabel != null) { this.buttonTrue.Visibility = Visibility.Visible; this.buttonTrue.Content = buttonTrueLabel; } if (buttonFalseLabel != null) { this.buttonFalse.Visibility = Visibility.Visible; this.buttonFalse.Content = buttonFalseLabel; } if (defaultChoice == true) { this.buttonTrue.IsDefault = true; } else { this.buttonFalse.IsDefault = true; } switch (icon) { case Icons.Information: image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Information.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); System.Media.SystemSounds.Asterisk.Play(); break; case Icons.Question: image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Question.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); System.Media.SystemSounds.Question.Play(); break; case Icons.Warning: image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Warning.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); System.Media.SystemSounds.Exclamation.Play(); break; case Icons.Error: image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Error.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); System.Media.SystemSounds.Hand.Play(); break; } // if only 1 button, make it cancel button if (buttonFalse.Visibility != Visibility.Visible) { buttonTrue.IsCancel = true; } }
void Calculate(Imaging.IImageFilter filter) { Calculate(filter, true); }
private void idCheck_MouseEnter(object sender, MouseEventArgs e) { idCheck.Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.중복확인눌린버전.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
public ImageFilterLookUpTable(Imaging.IImageFilter filter) : this(filter, true) { }
public static ImageSource ToImageSource(this Bitmap img) { return(Imaging.CreateBitmapSourceFromHBitmap(img.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); }
public void GetDefault() { var i = new Imaging(); var format = i.Get(null); Assert.IsNotNull(format as JpegFormat); format = i.Get(string.Empty); Assert.IsNotNull(format as JpegFormat); format = i.Get(" "); Assert.IsNotNull(format as JpegFormat); }
public ModListModel ParseEntry(JsonEntry entry) { ModListModel mlm = new ModListModel(); string race, map, part, type; if (entry.fullPath.Contains("weapon") || entry.fullPath.Contains("accessory") || entry.fullPath.Contains("decal") || entry.fullPath.Contains("vfx") || entry.fullPath.Contains("ui/")) { race = Strings.All; } else if (entry.fullPath.Contains("monster") || entry.fullPath.Contains("demihuman")) { race = Strings.Monster; } else { race = entry.fullPath.Substring(entry.fullPath.LastIndexOf('/')); if ((entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) && Properties.Settings.Default.DX_Ver.Equals(Strings.DX11)) { race = race.Substring(race.LastIndexOf("--c") + 3, 4); } else if (entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) { race = race.Substring(race.LastIndexOf("/c") + 2, 4); } else if (entry.fullPath.Contains("_c_")) { race = race.Substring(race.IndexOf("_c") + 2, 4); } else { if (entry.fullPath.Contains(".mdl") && entry.fullPath.Contains("_fac")) { race = race.Substring(race.IndexOf('c') + 1, 4); } else { race = race.Substring(race.LastIndexOf('c') + 1, 4); } } race = Info.IDRace[race]; } mlm.Race = race; if (entry.fullPath.Contains("_d.")) { map = Strings.Diffuse; } else if (entry.fullPath.Contains("_n.")) { map = Strings.Normal; } else if (entry.fullPath.Contains("_s.")) { map = Strings.Specular; } else if (entry.fullPath.Contains("material")) { map = Strings.ColorSet; } else if (entry.fullPath.Contains("model")) { map = "3D"; } else if (entry.fullPath.Contains("ui/")) { map = "UI"; } else { map = Strings.Mask; } mlm.Map = map; if (entry.fullPath.Contains("_b_")) { part = "b"; } else if (entry.fullPath.Contains("_c_")) { part = "c"; } else if (entry.fullPath.Contains("_d_")) { part = "d"; } else if (entry.fullPath.Contains("decal")) { part = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') + 1, entry.fullPath.LastIndexOf('.') - (entry.fullPath.LastIndexOf('_') + 1)); } else { part = "a"; } mlm.Part = part; if (entry.fullPath.Contains("_iri_")) { type = "Iris"; } else if (entry.fullPath.Contains("_etc_")) { type = "Etc."; } else if (entry.fullPath.Contains("_fac_")) { type = "Face"; } else if (entry.fullPath.Contains("_hir_")) { type = "Hair"; } else if (entry.fullPath.Contains("_acc_")) { type = "Accessory"; } else if (entry.fullPath.Contains("demihuman")) { type = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') - 3, 3); type = (Info.slotAbr).FirstOrDefault(x => x.Value == type).Key; } else { type = "-"; } mlm.Type = type; if (entry.fullPath.Contains("material")) { var info = MTRL.GetMTRLInfo(entry.modOffset, false); var bitmap = TEX.TextureToBitmap(info.ColorData, 9312, 4, 16); mlm.BMP = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); mlm.BMP.Freeze(); bitmap.Dispose(); } else if (entry.fullPath.Contains("model")) { mlm.BMP = new BitmapImage(new Uri("pack://application:,,,/FFXIV TexTools 2;component/Resources/3DModel.png")); } else { TEXData texData; if (entry.fullPath.Contains("vfx")) { texData = TEX.GetVFX(entry.modOffset, entry.datFile); } else { if (entry.fullPath.Contains("icon")) { texData = TEX.GetTex(entry.modOffset, entry.datFile); } else { texData = TEX.GetTex(entry.modOffset, entry.datFile); } } var scale = 1; if (texData.BMP.Width >= 4096 || texData.BMP.Width >= 4096) { scale = 8; } else if (texData.BMP.Width >= 2048 || texData.BMP.Width >= 2048) { scale = 4; } var oBMP = new Bitmap(texData.BMP); var nBMP = oBMP; if (scale > 1) { nBMP = new Bitmap(texData.BMP.Width / scale, texData.BMP.Height / scale); using (Graphics g = Graphics.FromImage(nBMP)) { g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.DrawImage(texData.BMP, new Rectangle(0, 0, nBMP.Width, nBMP.Height)); } } mlm.BMP = Imaging.CreateBitmapSourceFromHBitmap(nBMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); mlm.BMP.Freeze(); oBMP.Dispose(); nBMP.Dispose(); texData.Dispose(); } var offset = Helper.GetDataOffset(FFCRC.GetHash(entry.fullPath.Substring(0, entry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(entry.fullPath)), entry.datFile); if (offset == entry.modOffset) { mlm.ActiveBorder = Brushes.Green; mlm.Active = Brushes.Transparent; mlm.ActiveOpacity = 1; } else if (offset == entry.originalOffset) { mlm.ActiveBorder = Brushes.Red; mlm.Active = Brushes.Gray; mlm.ActiveOpacity = 0.5f; } else { mlm.ActiveBorder = Brushes.Red; mlm.Active = Brushes.Red; mlm.ActiveOpacity = 1; } mlm.Entry = entry; return(mlm); }
public void GetGif() { var expected = new GifFormat(); var i = new Imaging(); foreach (var extension in expected.FileExtensions) { var format = i.Get(extension); Assert.AreEqual(expected.GetType(), format.GetType()); } }
/// <summary> /// Bitmap转BitmapSource /// </summary> /// <param name="bitmap"></param> /// <returns></returns> internal static BitmapSource BitmapToBitmapSource(Bitmap bitmap) { return(Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); }
public void SizeDataNull() { var i = new Imaging(); i.Size(null); }
private void AppsToDeploy_Loaded(object sender, RoutedEventArgs e) { string path = App.config.get("softwarepath"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } List <string> dirs = new List <string>(); dirs.AddRange(Directory.GetFiles(path)); foreach (var sub in subDirectoryParameters) { string subPath = $@"{path}\{sub.Key}"; if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } dirs.AddRange(Directory.GetFiles(subPath)); } dirs.Sort(); var data = new List <SoftwareModel>(); foreach (var filePath in dirs) { var sysicon = System.Drawing.Icon.ExtractAssociatedIcon(filePath); var bmpSrc = Imaging.CreateBitmapSourceFromHIcon(sysicon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); sysicon.Dispose(); FileInfo fileInfo = new FileInfo(filePath); var itm = new SoftwareModel(); itm.icon = bmpSrc; itm.fileInfo = fileInfo; itm.size = Utils.getBytesReadable(fileInfo.Length); itm.file = fileInfo.Name; itm.path = filePath; if (fileInfo.Extension == ".msi") { itm.name = Utils.getMsiProperty(filePath, "ProductName"); itm.version = Utils.getMsiProperty(filePath, "ProductVersion"); itm.company = Utils.getMsiProperty(filePath, "Manufacturer"); } else { FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(filePath); itm.name = fileVersionInfo.ProductName?.Trim(); itm.version = fileVersionInfo.FileVersion; itm.company = fileVersionInfo.CompanyName?.Trim(); } data.Add(itm); } DataGrid_SoftwareList.ItemsSource = data; }
/// <summary> /// Creates the bitmap data for the models in the character category /// </summary> /// <remarks> /// Because the original textures use channel packing, this method gets the pixel data of each texture /// and then recombines them to create the unpacked textures to use in the 3D model. /// <see cref="http://wiki.polycount.com/wiki/ChannelPacking"/> /// </remarks> /// <param name="normalTexData">The texture data of the normal map</param> /// <param name="diffuseTexData">The texture data of the diffuse map</param> /// <param name="maskTexData">The texture data of the mask map</param> /// <param name="specularTexData">The texture data of the normal map</param> /// <returns>An array of bitmaps to be used on the model</returns> public static BitmapSource[] MakeCharacterMaps(TEXData normalTexData, TEXData diffuseTexData, TEXData maskTexData, TEXData specularTexData) { int height = normalTexData.Height; int width = normalTexData.Width; int tSize = height * width; Bitmap normalBitmap = null; if (diffuseTexData != null && (diffuseTexData.Height * diffuseTexData.Width) > tSize) { height = diffuseTexData.Height; width = diffuseTexData.Width; tSize = height * width; } if (maskTexData != null && (maskTexData.Height * maskTexData.Width) > tSize) { height = maskTexData.Height; width = maskTexData.Width; tSize = height * width; } if (specularTexData != null && (specularTexData.Height * specularTexData.Width) > tSize) { height = specularTexData.Height; width = specularTexData.Width; tSize = height * width; } byte[] maskPixels = null; byte[] specularPixels = null; byte[] normalPixels = null; byte[] diffusePixels = null; BitmapSource[] texBitmaps = new BitmapSource[4]; if (maskTexData != null) { if (tSize > (maskTexData.Height * maskTexData.Width)) { var maskBitmap = ResizeImage(Image.FromHbitmap(maskTexData.BMP.GetHbitmap()), width, height); var maskData = maskBitmap.LockBits(new System.Drawing.Rectangle(0, 0, maskBitmap.Width, maskBitmap.Height), ImageLockMode.ReadOnly, maskBitmap.PixelFormat); var bitmapLength = maskData.Stride * maskData.Height; maskPixels = new byte[bitmapLength]; Marshal.Copy(maskData.Scan0, maskPixels, 0, bitmapLength); maskBitmap.UnlockBits(maskData); } else { var maskData = maskTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, maskTexData.Width, maskTexData.Height), ImageLockMode.ReadOnly, maskTexData.BMP.PixelFormat); var bitmapLength = maskData.Stride * maskData.Height; maskPixels = new byte[bitmapLength]; Marshal.Copy(maskData.Scan0, maskPixels, 0, bitmapLength); maskTexData.BMP.UnlockBits(maskData); } } if (diffuseTexData != null) { try { if (tSize > (diffuseTexData.Height * diffuseTexData.Width)) { var diffuseBitmap = ResizeImage(Image.FromHbitmap(diffuseTexData.BMP.GetHbitmap()), width, height); var diffuseData = diffuseBitmap.LockBits(new System.Drawing.Rectangle(0, 0, diffuseBitmap.Width, diffuseBitmap.Height), ImageLockMode.ReadOnly, diffuseBitmap.PixelFormat); var bitmapLength = diffuseData.Stride * diffuseData.Height; diffusePixels = new byte[bitmapLength]; Marshal.Copy(diffuseData.Scan0, diffusePixels, 0, bitmapLength); diffuseBitmap.UnlockBits(diffuseData); } else { var diffuseData = diffuseTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, diffuseTexData.Width, diffuseTexData.Height), ImageLockMode.ReadOnly, diffuseTexData.BMP.PixelFormat); var bitmapLength = diffuseData.Stride * diffuseData.Height; diffusePixels = new byte[bitmapLength]; Marshal.Copy(diffuseData.Scan0, diffusePixels, 0, bitmapLength); diffuseTexData.BMP.UnlockBits(diffuseData); } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } } if (specularTexData != null) { try { if (tSize > (specularTexData.Height * specularTexData.Width)) { var specularBitmap = ResizeImage(Image.FromHbitmap(specularTexData.BMP.GetHbitmap()), width, height); var specularData = specularBitmap.LockBits(new System.Drawing.Rectangle(0, 0, specularBitmap.Width, specularBitmap.Height), ImageLockMode.ReadOnly, specularBitmap.PixelFormat); var bitmapLength = specularData.Stride * specularData.Height; specularPixels = new byte[bitmapLength]; Marshal.Copy(specularData.Scan0, specularPixels, 0, bitmapLength); specularBitmap.UnlockBits(specularData); } else { var specularData = specularTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, specularTexData.BMP.Width, specularTexData.BMP.Height), ImageLockMode.ReadOnly, specularTexData.BMP.PixelFormat); var bitmapLength = specularData.Stride * specularData.Height; specularPixels = new byte[bitmapLength]; Marshal.Copy(specularData.Scan0, specularPixels, 0, bitmapLength); specularTexData.BMP.UnlockBits(specularData); } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } } if (normalTexData != null) { if (tSize > (normalTexData.Height * normalTexData.Width)) { var normBitmap = ResizeImage(Image.FromHbitmap(normalTexData.BMP.GetHbitmap()), width, height); var normData = normBitmap.LockBits(new System.Drawing.Rectangle(0, 0, normBitmap.Width, normBitmap.Height), ImageLockMode.ReadOnly, normBitmap.PixelFormat); var bitmapLength = normData.Stride * normData.Height; normalPixels = new byte[bitmapLength]; Marshal.Copy(normData.Scan0, normalPixels, 0, bitmapLength); normBitmap.UnlockBits(normData); normalBitmap = normBitmap; } else { var normData = normalTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, normalTexData.Width, normalTexData.Height), ImageLockMode.ReadOnly, normalTexData.BMP.PixelFormat); var bitmapLength = normData.Stride * normData.Height; normalPixels = new byte[bitmapLength]; Marshal.Copy(normData.Scan0, normalPixels, 0, bitmapLength); normalTexData.BMP.UnlockBits(normData); normalBitmap = normalTexData.BMP; } } List <byte> diffuseMap = new List <byte>(); List <byte> specularMap = new List <byte>(); List <byte> alphaMap = new List <byte>(); BitmapSource bitmapSource; System.Drawing.Color diffuseColor; System.Drawing.Color specularColor; System.Drawing.Color alphaColor; int stride = normalBitmap.Width * (32 / 8); if (diffuseTexData == null) { for (int i = 3; i < normalPixels.Length; i += 4) { int alpha = normalPixels[i]; diffuseColor = System.Drawing.Color.FromArgb(alpha, (int)((96f / 255f) * specularPixels[i - 1]), (int)((57f / 255f) * specularPixels[i - 1]), (int)((19f / 255f) * specularPixels[i - 1])); specularColor = System.Drawing.Color.FromArgb(255, specularPixels[i - 2], specularPixels[i - 2], specularPixels[i - 2]); alphaColor = System.Drawing.Color.FromArgb(255, alpha, alpha, alpha); diffuseMap.AddRange(BitConverter.GetBytes(diffuseColor.ToArgb())); specularMap.AddRange(BitConverter.GetBytes(specularColor.ToArgb())); alphaMap.AddRange(BitConverter.GetBytes(alphaColor.ToArgb())); } bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, diffuseMap.ToArray(), stride); texBitmaps[0] = bitmapSource; } else { for (int i = 3; i < normalPixels.Length; i += 4) { int alpha = normalPixels[i - 3]; diffuseColor = System.Drawing.Color.FromArgb(alpha, diffusePixels[i - 1], diffusePixels[i - 2], diffusePixels[i - 3]); diffuseMap.AddRange(BitConverter.GetBytes(diffuseColor.ToArgb())); specularColor = System.Drawing.Color.FromArgb(255, specularPixels[i - 2], specularPixels[i - 2], specularPixels[i - 2]); specularMap.AddRange(BitConverter.GetBytes(specularColor.ToArgb())); alphaColor = System.Drawing.Color.FromArgb(255, alpha, alpha, alpha); alphaMap.AddRange(BitConverter.GetBytes(alphaColor.ToArgb())); } bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, diffuseMap.ToArray(), stride); texBitmaps[0] = bitmapSource; } bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, specularMap.ToArray(), stride); texBitmaps[1] = bitmapSource; texBitmaps[2] = Imaging.CreateBitmapSourceFromHBitmap(normalBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, alphaMap.ToArray(), stride); texBitmaps[3] = bitmapSource; if (normalTexData != null) { normalTexData.Dispose(); } if (normalBitmap != null) { normalBitmap.Dispose(); } if (diffuseTexData != null) { diffuseTexData.Dispose(); } if (maskTexData != null) { maskTexData.Dispose(); } if (specularTexData != null) { specularTexData.Dispose(); } return(texBitmaps); }
public ImageSource ImageSourceForBitmap(Bitmap bmp) { var handle = bmp.GetHbitmap(); return(Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); }
public void ResizeDataEmpty() { var i = new Imaging(); i.Resize(new byte[0], new ImageVersion()); }
private void setSemiTurn(String partName, bool clockWise) { int rotAngle = 0; if (clockWise) { rotAngle = 30; } else { rotAngle = -30; } System.Drawing.Bitmap texture = null; if (partName.Equals("top")) { mRotater.rotateTop(rotAngle); if (clockWise) { texture = FiveElementsIntTest.Properties.Resources.CubeArrowUpClock; } else { texture = FiveElementsIntTest.Properties.Resources.CubeArrowUpAnti; } } else if (partName.Equals("bottom")) { mRotater.rotateBottom(rotAngle); if (clockWise) { texture = FiveElementsIntTest.Properties.Resources.CubeArrowDownClock; } else { texture = FiveElementsIntTest.Properties.Resources.CubeArrowDownAnti; } } else if (partName.Equals("left")) { mRotater.rotateLeft(rotAngle); if (clockWise) { texture = FiveElementsIntTest.Properties.Resources.CubeArrowLeftClock; } else { texture = FiveElementsIntTest.Properties.Resources.CubeArrowLeftAnti; } } else if (partName.Equals("right")) { mRotater.rotateRight(rotAngle); if (clockWise) { texture = FiveElementsIntTest.Properties.Resources.CubeArrowRightClock; } else { texture = FiveElementsIntTest.Properties.Resources.CubeArrowRightAnti; } } else if (partName.Equals("front")) { mRotater.rotateFront(rotAngle); if (clockWise) { texture = FiveElementsIntTest.Properties.Resources.CubeArrowFrontClock; } else { texture = FiveElementsIntTest.Properties.Resources.CubeArrowFrontAnti; } } else if (partName.Equals("back")) { mRotater.rotateBack(rotAngle); if (clockWise) { texture = FiveElementsIntTest.Properties.Resources.CubeArrowBackClock; } else { texture = FiveElementsIntTest.Properties.Resources.CubeArrowBackAnti; } } //here to add the arrow if (texture != null) { if (mArrowPtr != IntPtr.Zero) { DeleteObject(mArrowPtr); mArrowPtr = IntPtr.Zero; } mArrowPtr = texture.GetHbitmap(); mOverlapImage.Source = Imaging.CreateBitmapSourceFromHBitmap( mArrowPtr, IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)mOverlapImage.Width, (int)mOverlapImage.Height)); } }
public void Resize() { var bytes = File.ReadAllBytes(Environment.CurrentDirectory + @"\icon.png"); var version = new ImageVersion() { Format = new GifFormat(), Width = 10, Height = 10, }; var i = new Imaging(); var data = i.Resize(bytes, version); Assert.IsNotNull(data); var size = i.Size(data); Assert.AreEqual(version.Width, size.Width); Assert.AreEqual(version.Height, size.Height); }
public MainWindow() { InitializeComponent(); original = System.Drawing.Image.FromFile(luciferPath) as Bitmap; for (int i = 0; i < 12; i++) { frames[i] = new Bitmap(100, 100); using (Graphics g = Graphics.FromImage(frames[i])) { g.DrawImage(original, new System.Drawing.Rectangle(0, 0, 100, 100), new System.Drawing.Rectangle(i * 100, 0, 100, 100), GraphicsUnit.Pixel); } var handle = frames[i].GetHbitmap(); try { imgFrame[i] = Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } finally { DeleteObject(handle); } } DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds((1 / hz) * delay); timer.Tick += NextFrame; timer.Start(); this.Topmost = true; MouseDown += MainWindow_MouseDown; var menu = new System.Windows.Forms.ContextMenu(); var noti = new System.Windows.Forms.NotifyIcon { Icon = System.Drawing.Icon.FromHandle(frames[0].GetHicon()), Visible = true, Text = "Helltaker", ContextMenu = menu, }; var exit = new System.Windows.Forms.MenuItem { Index = 1, Text = "종료", }; exit.Click += (object o, EventArgs e) => { Application.Current.Shutdown(); }; var onTop = new System.Windows.Forms.MenuItem { Index = 2, Text = "항상 위 켜짐", }; onTop.Click += (object o, EventArgs e) => { if (this.Topmost == true) { this.Topmost = false; onTop.Text = "항상 위 꺼짐"; } else { this.Topmost = true; onTop.Text = "항상 위 켜짐"; } }; //캐릭터 변수 var Azazel = new System.Windows.Forms.MenuItem { Text = "아자젤", }; var Cerberus = new System.Windows.Forms.MenuItem { Text = "케르베로스", }; var Helltaker_1 = new System.Windows.Forms.MenuItem { Text = "헬테이커 1", }; var Helltaker_2 = new System.Windows.Forms.MenuItem { Text = "헬테이커 2", }; var Judgement = new System.Windows.Forms.MenuItem { Text = "저지먼트", }; var Justice = new System.Windows.Forms.MenuItem { Text = "저스티스", }; var Lucifer_1 = new System.Windows.Forms.MenuItem { Text = ">루시퍼 1", }; var Lucifer_2 = new System.Windows.Forms.MenuItem { Text = "루시퍼 2", }; var Malina = new System.Windows.Forms.MenuItem { Text = "말리나", }; var Modeus = new System.Windows.Forms.MenuItem { Text = "모데우스", }; var Pandemonica = new System.Windows.Forms.MenuItem { Text = "판데모니카", }; var Skeleton = new System.Windows.Forms.MenuItem { Text = "스켈레톤", }; var Zdrada = new System.Windows.Forms.MenuItem { Text = "즈드라다", }; //캐릭터 선택 Azazel.Click += (object o, EventArgs e) => { Azazel.Text = ">아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Azazel(); }; Cerberus.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = ">케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Cerberus(); }; //Helltaker_1.Click += (object o, EventArgs e) => { // Azazel.Text = "아자젤"; // Cerberus.Text = "케르베로스"; // Helltaker_1.Text = ">헬테이커 1"; // Helltaker_2.Text = "헬테이커 2"; // Judgement.Text = "저지먼트"; // Justice.Text = "저스티스"; // Lucifer_1.Text = "루시퍼 1"; // Lucifer_2.Text = "루시퍼 2"; // Malina.Text = "말리나"; // Modeus.Text = "모데우스"; // Pandemonica.Text = "판데모니카"; // Skeleton.Text = "스켈레톤"; // Zdrada.Text = "즈드라다"; // this.Helltaker_1(); //}; //Helltaker_2.Click += (object o, EventArgs e) => { // Azazel.Text = "아자젤"; // Cerberus.Text = "케르베로스"; // Helltaker_1.Text = "헬테이커 1"; // Helltaker_2.Text = ">헬테이커 2"; // Judgement.Text = "저지먼트"; // Justice.Text = "저스티스"; // Lucifer_1.Text = "루시퍼 1"; // Lucifer_2.Text = "루시퍼 2"; // Malina.Text = "말리나"; // Modeus.Text = "모데우스"; // Pandemonica.Text = "판데모니카"; // Skeleton.Text = "스켈레톤"; // Zdrada.Text = "즈드라다"; // this.Helltaker_2(); //}; Judgement.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = ">저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Judgement(); }; Justice.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = ">저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Justice(); }; Lucifer_1.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = ">루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Lucifer_1(); }; Lucifer_2.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = ">루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Lucifer_2(); }; Malina.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = ">말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Malina(); }; Modeus.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = ">모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Modeus(); }; Pandemonica.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = ">판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = "즈드라다"; this.Pandemonica(); }; //Skeleton.Click += (object o, EventArgs e) => { // Azazel.Text = "아자젤"; // Cerberus.Text = "케르베로스"; // Helltaker_1.Text = "헬테이커 1"; // Helltaker_2.Text = "헬테이커 2"; // Judgement.Text = "저지먼트"; // Justice.Text = "저스티스"; // Lucifer_1.Text = "루시퍼 1"; // Lucifer_2.Text = "루시퍼 2"; // Malina.Text = "말리나"; // Modeus.Text = "모데우스"; // Pandemonica.Text = "판데모니카"; // Skeleton.Text = ">스켈레톤"; // Zdrada.Text = "즈드라다"; // this.Skeleton(); //}; Zdrada.Click += (object o, EventArgs e) => { Azazel.Text = "아자젤"; Cerberus.Text = "케르베로스"; Helltaker_1.Text = "헬테이커 1"; Helltaker_2.Text = "헬테이커 2"; Judgement.Text = "저지먼트"; Justice.Text = "저스티스"; Lucifer_1.Text = "루시퍼 1"; Lucifer_2.Text = "루시퍼 2"; Malina.Text = "말리나"; Modeus.Text = "모데우스"; Pandemonica.Text = "판데모니카"; Skeleton.Text = "스켈레톤"; Zdrada.Text = ">즈드라다"; this.Zdrada(); }; menu.MenuItems.Add(Lucifer_1); menu.MenuItems.Add(Lucifer_2); menu.MenuItems.Add(Malina); menu.MenuItems.Add(Modeus); menu.MenuItems.Add(Skeleton); menu.MenuItems.Add(Azazel); menu.MenuItems.Add(Justice); menu.MenuItems.Add(Judgement); menu.MenuItems.Add(Zdrada); menu.MenuItems.Add(Cerberus); menu.MenuItems.Add(Pandemonica); //menu.MenuItems.Add(Helltaker_1); //menu.MenuItems.Add(Helltaker_2); menu.MenuItems.Add(onTop); menu.MenuItems.Add(exit); noti.ContextMenu = menu; }
public void Save(System.IO.Stream stream, Imaging.ImageCodecInfo info, Imaging.EncoderParameters e) { Android.Graphics.Bitmap.CompressFormat _format; switch (info.FormatDescription) { case "PNG": _format = Android.Graphics.Bitmap.CompressFormat.Png; break; case "JPEG": default: _format = Android.Graphics.Bitmap.CompressFormat.Jpeg; break; } ABitmap.Compress(_format, 100, stream); }
public ConfirmationBox() { InitializeComponent(); _result = ConfirmationResult.Cancel; image.Source = Imaging.CreateBitmapSourceFromHIcon(SystemIcons.Question.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
public Imaging.BitmapData LockBits(Rectangle rect, Imaging.ImageLockMode flags, Imaging.PixelFormat format) { throw new NotImplementedException(); }
public void Save(System.IO.Stream stream, Imaging.ImageCodecInfo info, Imaging.EncoderParameters e) { }
public static ImageSource ConvertToImageSource(Icon Icon) { return(Imaging.CreateBitmapSourceFromHIcon(Icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); }
/// <summary> /// Creates the bitmap data for the model /// </summary> /// <remarks> /// Because the original textures use channel packing, this method gets the pixel data of each texture /// and then recombines them to create the unpacked textures to use in the 3D model. /// <see cref="http://wiki.polycount.com/wiki/ChannelPacking"/> /// </remarks> /// <param name="normalTexData">The texture data of the normal map</param> /// <param name="diffuseTexData">The texture data of the diffuse map</param> /// <param name="maskTexData">The texture data of the mask map</param> /// <param name="specularTexData">The texture data of the specular map</param> /// <param name="colorMap">The bitmap of the color map</param> /// <returns>An array of bitmaps to be used on the model</returns> public static BitmapSource[] MakeModelTextureMaps(TEXData normalTexData, TEXData diffuseTexData, TEXData maskTexData, TEXData specularTexData, BitmapSource colorMap) { int height = normalTexData.Height; int width = normalTexData.Width; int tSize = height * width; Bitmap normalBitmap = null; if (diffuseTexData != null && (diffuseTexData.Height * diffuseTexData.Width) > tSize) { height = diffuseTexData.Height; width = diffuseTexData.Width; tSize = height * width; } if (maskTexData != null && (maskTexData.Height * maskTexData.Width) > tSize) { height = maskTexData.Height; width = maskTexData.Width; tSize = height * width; } if (specularTexData != null && (specularTexData.Height * specularTexData.Width) > tSize) { height = specularTexData.Height; width = specularTexData.Width; tSize = height * width; } byte[] maskPixels = null; byte[] specularPixels = null; byte[] normalPixels = null; byte[] diffusePixels = null; List <System.Drawing.Color> colorList = new List <System.Drawing.Color>(); List <System.Drawing.Color> specularList = new List <System.Drawing.Color>(); BitmapSource[] texBitmaps = new BitmapSource[4]; if (colorMap != null) { int colorSetStride = colorMap.PixelWidth * (colorMap.Format.BitsPerPixel / 8); byte[] colorPixels = new byte[colorMap.PixelHeight * colorSetStride]; colorMap.CopyPixels(colorPixels, colorSetStride, 0); for (int i = 0; i < colorPixels.Length; i += 16) { int red = colorPixels[i + 2]; int green = colorPixels[i + 1]; int blue = colorPixels[i]; int alpha = colorPixels[i + 3]; colorList.Add(System.Drawing.Color.FromArgb(255, red, green, blue)); red = colorPixels[i + 6]; green = colorPixels[i + 5]; blue = colorPixels[i + 4]; alpha = colorPixels[i + 7]; specularList.Add(System.Drawing.Color.FromArgb(255, red, green, blue)); } } else if (colorMap == null) { for (int i = 0; i < 1024; i += 16) { colorList.Add(System.Drawing.Color.FromArgb(255, 255, 255, 255)); } } if (maskTexData != null) { if (tSize > (maskTexData.Height * maskTexData.Width)) { var maskBitmap = ResizeImage(Image.FromHbitmap(maskTexData.BMP.GetHbitmap()), width, height); var maskData = maskBitmap.LockBits(new System.Drawing.Rectangle(0, 0, maskBitmap.Width, maskBitmap.Height), ImageLockMode.ReadOnly, maskBitmap.PixelFormat); var bitmapLength = maskData.Stride * maskData.Height; maskPixels = new byte[bitmapLength]; Marshal.Copy(maskData.Scan0, maskPixels, 0, bitmapLength); maskBitmap.UnlockBits(maskData); } else { var maskData = maskTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, maskTexData.Width, maskTexData.Height), ImageLockMode.ReadOnly, maskTexData.BMP.PixelFormat); var bitmapLength = maskData.Stride * maskData.Height; maskPixels = new byte[bitmapLength]; Marshal.Copy(maskData.Scan0, maskPixels, 0, bitmapLength); maskTexData.BMP.UnlockBits(maskData); } } if (diffuseTexData != null) { if (tSize > (diffuseTexData.Height * diffuseTexData.Width)) { var diffuseBitmap = ResizeImage(Image.FromHbitmap(diffuseTexData.BMP.GetHbitmap()), width, height); var diffData = diffuseBitmap.LockBits(new System.Drawing.Rectangle(0, 0, diffuseBitmap.Width, diffuseBitmap.Height), ImageLockMode.ReadOnly, diffuseBitmap.PixelFormat); var bitmapLength = diffData.Stride * diffData.Height; diffusePixels = new byte[bitmapLength]; Marshal.Copy(diffData.Scan0, diffusePixels, 0, bitmapLength); diffuseBitmap.UnlockBits(diffData); } else { var diffData = diffuseTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, diffuseTexData.Width, diffuseTexData.Height), ImageLockMode.ReadOnly, diffuseTexData.BMP.PixelFormat); var bitmapLength = diffData.Stride * diffData.Height; diffusePixels = new byte[bitmapLength]; Marshal.Copy(diffData.Scan0, diffusePixels, 0, bitmapLength); diffuseTexData.BMP.UnlockBits(diffData); } } if (specularTexData != null) { if (tSize > (specularTexData.Height * specularTexData.Width)) { var specularBitmap = ResizeImage(Image.FromHbitmap(specularTexData.BMP.GetHbitmap()), width, height); var specData = specularBitmap.LockBits(new System.Drawing.Rectangle(0, 0, specularBitmap.Width, specularBitmap.Height), ImageLockMode.ReadOnly, specularBitmap.PixelFormat); var bitmapLength = specData.Stride * specData.Height; specularPixels = new byte[bitmapLength]; Marshal.Copy(specData.Scan0, specularPixels, 0, bitmapLength); specularBitmap.UnlockBits(specData); } else { var specData = specularTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, specularTexData.BMP.Width, specularTexData.BMP.Height), ImageLockMode.ReadOnly, specularTexData.BMP.PixelFormat); var bitmapLength = specData.Stride * specData.Height; specularPixels = new byte[bitmapLength]; Marshal.Copy(specData.Scan0, specularPixels, 0, bitmapLength); specularTexData.BMP.UnlockBits(specData); } } if (normalTexData != null) { if (tSize > (normalTexData.Height * normalTexData.Height)) { var normBitmap = ResizeImage(Image.FromHbitmap(normalTexData.BMP.GetHbitmap()), width, height); var normalData = normBitmap.LockBits(new System.Drawing.Rectangle(0, 0, normBitmap.Width, normBitmap.Height), ImageLockMode.ReadOnly, normBitmap.PixelFormat); var bitmapLength = normalData.Stride * normalData.Height; normalPixels = new byte[bitmapLength]; Marshal.Copy(normalData.Scan0, normalPixels, 0, bitmapLength); normBitmap.UnlockBits(normalData); normalBitmap = normBitmap; } else { var normalData = normalTexData.BMP.LockBits(new System.Drawing.Rectangle(0, 0, normalTexData.Width, normalTexData.Height), ImageLockMode.ReadOnly, normalTexData.BMP.PixelFormat); var bitmapLength = normalData.Stride * normalData.Height; normalPixels = new byte[bitmapLength]; Marshal.Copy(normalData.Scan0, normalPixels, 0, bitmapLength); normalTexData.BMP.UnlockBits(normalData); normalBitmap = normalTexData.BMP; } } List <byte> diffuseMap = new List <byte>(); List <byte> specularMap = new List <byte>(); List <byte> alphaMap = new List <byte>(); float R = 1; float G = 1; float B = 1; float R1 = 1; float G1 = 1; float B1 = 1; for (int i = 3; i < normalPixels.Length; i += 4) { int alpha = normalPixels[i - 3]; if (maskTexData != null) { B = maskPixels[i - 1]; R = maskPixels[i - 1]; G = maskPixels[i - 1]; B1 = maskPixels[i - 3]; R1 = maskPixels[i - 3]; G1 = maskPixels[i - 3]; } else { B = diffusePixels[i - 3]; G = diffusePixels[i - 2]; R = diffusePixels[i - 1]; B1 = specularPixels[i - 2]; G1 = specularPixels[i - 2]; R1 = specularPixels[i - 2]; } float pixel = (normalPixels[i] / 255f) * 15f; int colorLoc = (int)Math.Floor(pixel + 0.5f); System.Drawing.Color diffuseColor; System.Drawing.Color specularColor; System.Drawing.Color alphaColor; diffuseColor = System.Drawing.Color.FromArgb(alpha, (int)((colorList[colorLoc].R / 255f) * R), (int)((colorList[colorLoc].G / 255f) * G), (int)((colorList[colorLoc].B / 255f) * B)); specularColor = System.Drawing.Color.FromArgb(255, (int)((specularList[colorLoc].R / 255f) * R1), (int)((specularList[colorLoc].G / 255f) * G1), (int)((specularList[colorLoc].B / 255f) * B1)); alphaColor = System.Drawing.Color.FromArgb(255, alpha, alpha, alpha); diffuseMap.AddRange(BitConverter.GetBytes(diffuseColor.ToArgb())); specularMap.AddRange(BitConverter.GetBytes(specularColor.ToArgb())); alphaMap.AddRange(BitConverter.GetBytes(alphaColor.ToArgb())); } int stride = normalBitmap.Width * (32 / 8); BitmapSource bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, diffuseMap.ToArray(), stride); texBitmaps[0] = bitmapSource; bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, specularMap.ToArray(), stride); texBitmaps[1] = bitmapSource; var noAlphaNormal = SetAlpha(normalBitmap, 255); texBitmaps[2] = Imaging.CreateBitmapSourceFromHBitmap(noAlphaNormal.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); bitmapSource = BitmapSource.Create(width, height, normalBitmap.HorizontalResolution, normalBitmap.VerticalResolution, PixelFormats.Bgra32, null, alphaMap.ToArray(), stride); texBitmaps[3] = bitmapSource; if (normalTexData != null) { normalTexData.Dispose(); } if (normalBitmap != null) { normalBitmap.Dispose(); } if (diffuseTexData != null) { diffuseTexData.Dispose(); } if (maskTexData != null) { maskTexData.Dispose(); } if (specularTexData != null) { specularTexData.Dispose(); } return(texBitmaps); }
public void Load() { telegram.udpChatClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); telegram.udpChatClient.Client.Bind(new IPEndPoint(IPAddress.Any, telegram.receivePort)); telegram.udpChatClient.JoinMulticastGroup(IPAddress.Parse("224.5.5.5")); telegram.userInfoFrame.Navigate(telegram.userInfoPage); telegram.userInfoPage.Visibility = Visibility.Hidden; telegram.userInfoPage.userName.Content = telegram.user.name; telegram.mainFrame.Visibility = Visibility.Hidden; telegram.userInfoPage.addGroupButton.Click += telegram.clickHandler.AddNewGroupButton_Click; Bitmap bitmap = Resource1.Telegram_icon.ToBitmap(); IntPtr hBitmap = bitmap.GetHbitmap(); telegram.Icon = Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); telegram.createGroupFrame.Navigate(telegram.addNewGroup); telegram.addNewGroup.createButton.Click += telegram.clickHandler.CreateGroupButton_Click; telegram.addNewGroup.Visibility = Visibility.Hidden; telegram.listGroupFrame.Navigate(telegram.groupList); telegram.groupList.Visibility = Visibility.Hidden; telegram.groupList.joinButton.Click += telegram.clickHandler.JoinButton_Click; telegram.showContactsFrame.Navigate(telegram.contactsPage); telegram.contactsPage.Visibility = Visibility.Hidden; telegram.contactsPage.addContactButton.Click += telegram.clickHandler.AddContactButton_Click; telegram.userInfoPage.contactsButton.Click += telegram.clickHandler.ShowContactsButton_Click; Button button = new Button(); button.Content = ""; System.Windows.Media.Color color = new System.Windows.Media.Color(); color.R = 0; color.G = 0; color.B = 0; telegram.searchGroup.GotMouseCapture += telegram.clickHandler.MouseCapture; telegram.searchGroup.TextChanged += telegram.clickHandler.SearchGroupText_Changed; SolidColorBrush brush = new SolidColorBrush(color); button.Background = brush; button.Background.Opacity = 35; button.Click += telegram.clickHandler.CloseInfoPage_Click; telegram.mainFrame.Navigate(button); ImageSource image = Imaging.CreateBitmapSourceFromHBitmap( Resource1.chatPage.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); ImageBrush imageBrush = new ImageBrush(image); telegram.chatPage.Background = imageBrush; image = Imaging.CreateBitmapSourceFromHBitmap( Resource1.Voice.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); imageBrush = new ImageBrush(image); telegram.fileButton.Click += telegram.clickHandler.fileButton_Click; telegram.sendButton.Click += telegram.clickHandler.sendButton_Click; telegram.voiceButton.Click += telegram.clickHandler.voiceButton_Click; telegram.infoPage.Click += telegram.clickHandler.InfoPageButton_Click; telegram.voiceButton.Background = imageBrush; telegram.listbox.SelectionChanged += telegram.clickHandler.SelectionChanged; telegram.joinGroupButton.Click += telegram.clickHandler.JoinGroupButton_Click; }
public static BitmapSource ConvertToBitmapSource(System.Drawing.Bitmap gdiPlusBitmap) { IntPtr hBitmap = gdiPlusBitmap.GetHbitmap(); return(Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); }
public void Save(System.IO.Stream stream, Imaging.ImageFormat format) { throw new NotImplementedException(); }
protected override ImageSource Convert(FileSystemItemViewModel viewModel, Type targetType) { if (viewModel == null) { return(null); } var rm = viewModel.ResourceManager; var bytes = viewModel.IsUpDirectory ? null : viewModel.Thumbnail; if (bytes == null) { string icon; switch (viewModel.Type) { case ItemType.Directory: if (viewModel.IsUpDirectory) { icon = "up"; } else if (viewModel.Name == "0000000000000000") { icon = "games_folder"; } else if (viewModel.Model.RecognitionState == RecognitionState.PartiallyRecognized) { icon = "xbox_logo"; } else if (viewModel.IsRefreshing) { icon = "refresh_folder"; } else { icon = "folder"; } break; case ItemType.Link: icon = "reparse_point"; break; case ItemType.File: if (viewModel.IsCompressedFile) { icon = "package"; } else if (viewModel.IsIso) { icon = "iso"; } else if (viewModel.IsXex) { icon = "xex"; } else { ImageSource image = null; var extension = Path.GetExtension(viewModel.Name); if (!string.IsNullOrEmpty(extension)) { var key = ThumbnailSize + extension; if (SystemIconCache.ContainsKey(key)) { image = SystemIconCache[key]; } else { try { var shinfo = new ShellFileInfo(); var path = viewModel.Path; if (!File.Exists(path)) { path = key; //creating a temporary dummy file, i.e. 16.png using (File.Create(path)) {} } var size = ThumbnailSize == 16 ? (uint)1 : 0; IconExtensions.SHGetFileInfo(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), 0x100 | size); if (path != viewModel.Path) { File.Delete(path); } if (IntPtr.Zero != shinfo.hIcon) { image = Imaging.CreateBitmapSourceFromHIcon(shinfo.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } } catch { } SystemIconCache.Add(key, image); } if (image != null) { return(image); } } icon = "file"; } break; case ItemType.Drive: switch (viewModel.Model.DriveType) { case DriveType.CDRom: icon = "drive_cd"; break; case DriveType.Network: icon = "drive_network"; break; case DriveType.Removable: icon = "drive_flash"; break; default: icon = "drive"; break; } break; default: throw new NotSupportedException("Invalid item type: " + viewModel.Type); } bytes = rm.GetContentByteArray(string.Format("/Resources/Items/{0}x{0}/{1}.png", ThumbnailSize, icon)); } return(bytes[0] == 0 ? null : StfsPackageExtensions.GetBitmapFromByteArray(bytes)); }
unsafe public static BitmapSource Create( int pixelWidth, int pixelHeight, double dpiX, double dpiY, PixelFormat pixelFormat, Imaging.BitmapPalette palette, IntPtr buffer, int bufferSize, int stride ) { SecurityHelper.DemandUnmanagedCode(); return new CachedBitmap( pixelWidth, pixelHeight, dpiX, dpiY, pixelFormat, palette, buffer, bufferSize, stride); }
public void EnumerateMetafile(Imaging.Metafile metafile, Point destPoint, Graphics.EnumerateMetafileProc callback) { throw new NotImplementedException(); }