Skip to content

Commit

Permalink
Create pixutils.formats module
Browse files Browse the repository at this point in the history
  • Loading branch information
tomba committed Aug 29, 2024
1 parent 246ed07 commit 56f1315
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 21 deletions.
4 changes: 0 additions & 4 deletions pixutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from __future__ import annotations

from .pixelformats import *
from .metaformats import *
3 changes: 1 addition & 2 deletions pixutils/conv/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import numpy as np
import numpy.typing as npt

from pixutils import PixelFormat
from pixutils.pixelformats import PixelColorEncoding
from pixutils.formats import PixelFormat, PixelColorEncoding

from .yuv import yuv_to_bgr888
from .rgb import rgb_to_bgr888
Expand Down
4 changes: 2 additions & 2 deletions pixutils/conv/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from __future__ import annotations

from PyQt6 import QtGui
from pixutils import PixelFormat
from .conv import PixelFormats, buffer_to_bgr888
from pixutils.formats import PixelFormat, PixelFormats
from .conv import buffer_to_bgr888

def bgr888_to_pix(rgb):
# QImage doesn't seem to like a numpy view
Expand Down
2 changes: 1 addition & 1 deletion pixutils/conv/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import numpy.typing as npt

from pixutils import PixelFormat
from pixutils.formats import PixelFormat

__all__ = [ 'raw_to_bgr888' ]

Expand Down
2 changes: 1 addition & 1 deletion pixutils/conv/rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import numpy.typing as npt

from pixutils import PixelFormat, PixelFormats
from pixutils.formats import PixelFormat, PixelFormats

def rgb_to_bgr888(fmt: PixelFormat, w, h, data: npt.NDArray[np.uint8]):
if fmt == PixelFormats.RGB888:
Expand Down
3 changes: 2 additions & 1 deletion pixutils/conv/yuv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import numpy as np
import numpy.typing as npt
from pixutils import PixelFormats

from pixutils.formats import PixelFormats

YCBCR_VALUES = {
'bt601': {
Expand Down
3 changes: 3 additions & 0 deletions pixutils/formats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .pixelformats import *
from .metaformats import *
from .fourcc_str import *
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions tests/test_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import unittest
import numpy as np

from pixutils import PixelFormats
from pixutils.formats import PixelFormats, str_to_fourcc
from pixutils.conv import buffer_to_bgr888
from pixutils.fourcc_str import str_to_fourcc

TEST_PATH = os.path.dirname(os.path.abspath(__file__))

Expand Down
12 changes: 6 additions & 6 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

import unittest
import pixutils
import pixutils.fourcc_str
import pixutils.formats

class TestDummy(unittest.TestCase):
def test_dummy(self):
self.assertEqual(pixutils.PixelFormats.RGB888.name, 'RGB888')
self.assertEqual(pixutils.formats.PixelFormats.RGB888.name, 'RGB888')

class TestFourcc(unittest.TestCase):
def test_fourcc(self):
self.assertEqual(pixutils.fourcc_str.str_to_fourcc('XR24'), 0x34325258)
self.assertEqual(pixutils.fourcc_str.fourcc_to_str(0x34325258), 'XR24')
self.assertEqual(pixutils.formats.fourcc_str.str_to_fourcc('XR24'), 0x34325258)
self.assertEqual(pixutils.formats.fourcc_str.fourcc_to_str(0x34325258), 'XR24')
with self.assertRaises(ValueError):
pixutils.fourcc_str.str_to_fourcc('ABCDE')
pixutils.formats.fourcc_str.str_to_fourcc('ABCDE')
with self.assertRaises(ValueError):
pixutils.fourcc_str.str_to_fourcc('ABC')
pixutils.formats.fourcc_str.str_to_fourcc('ABC')

if __name__ == '__main__':
unittest.main()
3 changes: 1 addition & 2 deletions tests/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
from PyQt6.QtCore import Qt
from PyQt6 import QtWidgets

from pixutils import PixelFormats
from pixutils.formats import PixelFormats, str_to_fourcc
from pixutils.conv import buffer_to_bgr888
from pixutils.conv.qt import bgr888_to_pix
from pixutils.fourcc_str import str_to_fourcc

TEST_PATH = os.path.dirname(os.path.abspath(__file__))

Expand Down

0 comments on commit 56f1315

Please sign in to comment.