Skip to content

Commit

Permalink
Add type hints, update libjpeg, allow returning bytearray (pydicom#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion authored Jan 5, 2024
1 parent a2d5d28 commit 2e400b0
Show file tree
Hide file tree
Showing 22 changed files with 2,176 additions and 2,381 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: wheels
name: sdist
path: ./dist

build-wheels:
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheel-${{ matrix.python }}-${{ matrix.platform_id }}
path: ./dist

test-package:
Expand All @@ -206,8 +206,8 @@ jobs:
- name: Download the wheels
uses: actions/download-artifact@v4
with:
name: wheels
path: dist/
merge-multiple: true

- name: Install from package wheels and test
# If testing wheel builds might need --pre to install dev version
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down Expand Up @@ -56,7 +55,7 @@ coverage.xml
*.pot

# Django stuff:
*.log
#*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "libjpeg/src/libjpeg"]
path = libjpeg/src/libjpeg
path = lib/libjpeg
url = https://github.com/thorfdbg/libjpeg.git
5 changes: 3 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


PACKAGE_DIR = Path(__file__).parent / "libjpeg"
LIBJPEG_SRC = PACKAGE_DIR / 'src' / 'libjpeg'
INTERFACE_SRC = PACKAGE_DIR / 'src' / 'interface'
LIB_DIR = Path(__file__).parent / "lib"
LIBJPEG_SRC = LIB_DIR / 'libjpeg'
INTERFACE_SRC = LIB_DIR / 'interface'


def build(setup_kwargs: Any) -> Any:
Expand Down
16 changes: 12 additions & 4 deletions libjpeg/src/interface/decode.cpp → lib/interface/decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
#include "../libjpeg/interface/jpeg.hpp"


std::string Decode(char *inArray, char *outArray, int inLength, int outLength, int colourTransform)
{
std::string Decode(
char *inArray,
char *outArray,
int inLength,
int outLength,
int colourTransform
) {
/*
Parameters
Expand Down Expand Up @@ -254,8 +259,11 @@ std::string Decode(char *inArray, char *outArray, int inLength, int outLength, i
}


std::string GetJPEGParameters(char *inArray, int inLength, struct JPEGParameters *param)
{
std::string GetJPEGParameters(
char *inArray,
int inLength,
struct JPEGParameters *param
) {
/*
Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

// Return the parameters of the encoded JPEG file in `inArray`
extern std::string GetJPEGParameters(
char *inArray, int inLength, struct JPEGParameters *param
char *inArray,
int inLength,
struct JPEGParameters *param
);

struct StreamData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ JPG_LONG IStreamHook(struct JPG_Hook *hook, struct JPG_TagItem *tags)
}
case JPGFLAG_ACTION_WRITE:
{
UBYTE *buffer = (UBYTE *)tags->GetTagPtr(JPGTAG_FIO_BUFFER);
ULONG size = (ULONG )tags->GetTagData(JPGTAG_FIO_SIZE);
// UBYTE *buffer = (UBYTE *)tags->GetTagPtr(JPGTAG_FIO_BUFFER);
// ULONG size = (ULONG )tags->GetTagData(JPGTAG_FIO_SIZE);

// We want to raise an error so writing can be implemented
return -1;
}
case JPGFLAG_ACTION_SEEK:
{
LONG mode = tags->GetTagData(JPGTAG_FIO_SEEKMODE);
LONG offset = tags->GetTagData(JPGTAG_FIO_OFFSET);
// LONG offset = tags->GetTagData(JPGTAG_FIO_OFFSET);

// We want to raise an error here seek can be implemented
switch(mode) {
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/libjpeg
Submodule libjpeg added at db33a6
Loading

0 comments on commit 2e400b0

Please sign in to comment.