Skip to content

Commit

Permalink
Read icon in blocks
Browse files Browse the repository at this point in the history
...jpype is so smart!
  • Loading branch information
gselzer committed Aug 17, 2023
1 parent fc05f21 commit ff7a205
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/napari_imagej/widgets/widget_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import lru_cache
from typing import List

from jpype import JArray, JByte
from magicgui import magicgui
from napari import Viewer
from napari.layers import Image, Labels, Layer, Points, Shapes
Expand Down Expand Up @@ -300,11 +301,12 @@ def _getIcon(icon_path):
return
stream = jc.File.class_.getResourceAsStream(icon_path)
bytes_array = bytearray()
foo = JArray(JByte)(1024)
while True:
b = stream.read()
if b == -1:
length = stream.read(foo, 0, foo.length)
if length == -1:
break
bytes_array.append(b)
bytes_array.extend(foo)

Check warning on line 309 in src/napari_imagej/widgets/widget_utils.py

View check run for this annotation

Codecov / codecov/patch

src/napari_imagej/widgets/widget_utils.py#L302-L309

Added lines #L302 - L309 were not covered by tests

pixmap = QPixmap()
pixmap.loadFromData(QByteArray(bytes_array))

Check warning on line 312 in src/napari_imagej/widgets/widget_utils.py

View check run for this annotation

Codecov / codecov/patch

src/napari_imagej/widgets/widget_utils.py#L311-L312

Added lines #L311 - L312 were not covered by tests
Expand Down

0 comments on commit ff7a205

Please sign in to comment.