public void View(string path, ContextObject context) { var header = NativeMethods.FitsImageGetHeader(_fitsImagePtr); ImageDim outputDim = NativeMethods.FitsImageGetOutputDim(_fitsImagePtr); byte[] img = new byte[outputDim.nx * outputDim.ny * outputDim.nc]; NativeMethods.FitsImageGetPixData(_fitsImagePtr, img); BitmapSource bitmapSource; int rawStride = outputDim.nx * outputDim.nc; if (outputDim.nc == 3) { bitmapSource = BitmapSource.Create(outputDim.nx, outputDim.ny, 96, 96, PixelFormats.Rgb24, null, img, rawStride); } else { bitmapSource = BitmapSource.Create(outputDim.nx, outputDim.ny, 96, 96, PixelFormats.Gray8, null, img, rawStride); } _ip = new ImagePanel(context, header); context.ViewerContent = _ip; context.Title = $"{Path.GetFileName(path)}"; _ip.Source = bitmapSource; context.IsBusy = false; }
public void Prepare(string path, ContextObject context) { _fitsImagePtr = NativeMethods.FitsImageCreate(path); ImageDim outputDim = NativeMethods.FitsImageGetOutputDim(_fitsImagePtr); var size = new Size(outputDim.nx, outputDim.ny); context.SetPreferredSizeFit(size, 0.8); }