Skip to content

Commit aed8cea

Browse files
authored
Fix bitmap adapter test (#59)
1 parent 5d73852 commit aed8cea

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rendercanvas/utils/bitmappresentadapter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class BitmapPresentAdapter:
1010
"""An adapter to present a bitmap to a canvas using wgpu.
1111
1212
This adapter can be used by context objects that want to present a bitmap, when the
13-
canvas only supoorts presenting to screen.
13+
canvas only supports presenting to screen.
1414
"""
1515

1616
def __init__(self, canvas, present_methods):
@@ -37,6 +37,10 @@ def present_bitmap(self, bitmap):
3737

3838
if not self._context_is_configured:
3939
format = self._context.get_preferred_format(self._device.adapter)
40+
# We don't want an srgb texture, because we assume the input bitmap is already srgb.
41+
# AFAIK contexts always support both the regular and the srgb texture format variants
42+
if format.endswith("-srgb"):
43+
format = format[:-5]
4044
self._context.configure(device=self._device, format=format)
4145

4246
target = self._context.get_current_texture().create_view()

tests/test_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def test_bitmap_context():
210210

211211

212212
@pytest.mark.skipif(not can_use_wgpu_lib, reason="Needs wgpu lib")
213-
def test_bitmap_to_screen_adapter():
213+
def test_bitmap_present_adapter():
214214
# Create canvas and attach our special adapter canvas
215215
canvas = ManualOffscreenRenderCanvas()
216216
context = canvas.get_context(__name__ + ":SpecialContextWithWgpuAdapter")

0 commit comments

Comments
 (0)