{"record":{"id":"ec01e4ba2ca6cad1","repo":"tui-cs/Terminal.Gui","slug":"no-raster-graphics-support-available","errorCode":null,"errorMessage":"No raster graphics support available.","messagePattern":"No raster graphics support available\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Views/ImageView/ImageView.cs","lineNumber":328,"sourceCode":"    ///     Gets whether the current rendering mode is using sixel.\n    /// </summary>\n    [Obsolete (\"Use IsUsingRasterGraphics instead. IsUsingSixel will be removed in a future version.\")]\n    public bool IsUsingSixel => UseRasterGraphics && !IsKittyGraphicsActive () && App?.Driver?.SixelSupport is { IsSupported: true };\n\n    /// <summary>\n    ///     Converts the Viewport to screen coordinates in pixels.\n    /// </summary>\n    /// <remarks>\n    ///     <para>\n    ///         This method accounts for the terminal's cell resolution and the viewport's\n    ///         size, returning the exact pixel dimensions and position required for\n    ///         fully cover the viewport.\n    ///     </para>\n    /// </remarks>\n    /// <returns>The screen coordinates of the Viewport in pixels.</returns>\n    public Rectangle ViewportToScreenInPixels ()\n    {\n        Size resolution = GetActiveResolution () ?? throw new InvalidOperationException (@\"No raster graphics support available.\");\n\n        int pixelsPerCellX = resolution.Width;\n        int pixelsPerCellY = resolution.Height;\n        Rectangle boundsRect = ViewportToScreen ();\n\n        int targetWidthInPixels = boundsRect.Width * pixelsPerCellX;\n        int targetHeightInPixels = IsKittyGraphicsActive ()\n                                       ? boundsRect.Height * pixelsPerCellY\n                                       : SixelEncoder?.GetHeightInPixels (boundsRect.Height, pixelsPerCellY) ?? boundsRect.Height * pixelsPerCellY;\n\n        return new Rectangle (boundsRect.X * pixelsPerCellX, boundsRect.Y * pixelsPerCellY, targetWidthInPixels, targetHeightInPixels);\n    }\n\n    /// <summary>\n    ///     Returns the resolution (pixels per cell) for the active raster graphics protocol,\n    ///     preferring Kitty over Sixel.  Returns <see langword=\"null\"/> when neither is available.\n    /// </summary>\n    private Size? GetActiveResolution ()","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Views/ImageView/ImageView.cs#L310-L346","documentation":"Thrown by ImageView.ViewportToScreenInPixels when GetActiveResolution() returns null, meaning the terminal/driver provides no raster graphics pixel resolution (neither Kitty nor Sixel cell-pixel dimensions are available). The method exists to compute screen pixel coordinates for raster drawing, so without a resolution there is no meaningful result and it fails fast rather than returning a garbage rectangle.","triggerScenarios":"Calling ViewportToScreenInPixels() on a driver/terminal that does not report raster graphics support, or calling it before the ImageView has determined its active raster mode (e.g. before first render or when UseRasterGraphics is false).","commonSituations":"Running under a plain ANSI/Curses driver or a terminal without sixel/Kitty; calling during design/preview mode; running in CI with a null/fake driver that omits SixelSupport.","solutions":["Gate the call on IsUsingRasterGraphics (or check App?.Driver?.SixelSupport?.IsSupported) before invoking ViewportToScreenInPixels.","Avoid calling this method for character-cell rendering paths; it is only meaningful when raster output is active.","If you must compute pixel rects defensively, fall back to cell-based math (Viewport width/height in cells) when raster is unavailable."],"exampleFix":"// before\nRectangle px = imageView.ViewportToScreenInPixels(); // throws 164\n\n// after\nRectangle px = imageView.IsUsingRasterGraphics\n    ? imageView.ViewportToScreenInPixels()\n    : imageView.Viewport;","handlingStrategy":"type-guard","validationCode":"Rectangle px = imageView.IsUsingRasterGraphics\n    ? imageView.ViewportToScreenInPixels()\n    : imageView.Viewport;","typeGuard":"static bool HasRasterSupport(ImageView v) => v.IsUsingRasterGraphics;","tryCatchPattern":null,"preventionTips":["Only call ViewportToScreenInPixels when raster graphics are active.","Gate on App?.Driver?.SixelSupport?.IsSupported in lower-level code.","Avoid the method in CI/headless unless the driver reports raster support."],"tags":["imageview","raster","validation","environment"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}