diff --git a/.drone.yml b/.drone.yml index 3f03ddd5..301df037 100644 --- a/.drone.yml +++ b/.drone.yml @@ -225,34 +225,42 @@ steps: commands: - pacman --noconfirm -Syu - sudo -u aur yay --noconfirm -S vpv - --- + kind: pipeline type: docker -name: ubuntu-xenial-mkappimage +name: ubuntu-bionic-mkappimage steps: - name: mkappimage - image: ubuntu:xenial + image: ubuntu:bionic commands: - apt-get update - apt-get install -qq build-essential cmake wget - - apt-get install -qq libsdl2-dev libpng-dev libtiff-dev libjpeg-dev - - apt-get remove -qq libsdl2-dev # remove it but keep the dependencies - - wget https://www.libsdl.org/release/SDL2-2.0.12.tar.gz - - tar xvf SDL2-*.tar.gz - - cd SDL2-*/ - - ./configure - - make - - make install - - cd .. + - apt-get install -qq libsdl2-dev libpng-dev libtiff-dev libjpeg-dev libgdal-dev + #- apt-get remove -qq libsdl2-dev # remove it but keep the dependencies + #- wget https://www.libsdl.org/release/SDL2-2.0.12.tar.gz + #- tar xvf SDL2-*.tar.gz + #- cd SDL2-*/ + #- ./configure + #- make -j6 + #- make install + #- cd .. - mkdir build - cd build - - cmake .. -DCMAKE_INSTALL_PREFIX=/usr - - make + - cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DUSE_GDAL=ON + - make -j6 - make install DESTDIR=AppDir - wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage - chmod +x linuxdeploy-x86_64.AppImage - ./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir/ --executable AppDir/usr/bin/vpv --icon-file=../misc/icon.svg --output appimage - - # upload if branch==dev +- name: publish + image: plugins/github-release + settings: + api_key: + from_secret: github_token + draft: true + files: build/vpv-*.AppImage + when: + event: tag diff --git a/external/iio/iio.c b/external/iio/iio.c index 7d083652..9d0ce87d 100644 --- a/external/iio/iio.c +++ b/external/iio/iio.c @@ -1673,10 +1673,10 @@ static int read_whole_tiff(struct iio_image *x, const char *filename) return 0; } go_on: - if (!broken) - assert((int)scanline_size == sls); - else - assert((int)scanline_size == spp*sls); + /*if (!broken)*/ + /*assert((int)scanline_size == sls);*/ + /*else*/ + /*assert((int)scanline_size == spp*sls);*/ assert((int)scanline_size >= sls); uint8_t *data = xmalloc(w * h * spp * rbps * (complicated?2:1)); uint8_t *buf = xmalloc(scanline_size); diff --git a/external/iio/npy.c b/external/iio/npy.c index a277b0d4..5c160afa 100644 --- a/external/iio/npy.c +++ b/external/iio/npy.c @@ -153,7 +153,7 @@ int npy_read_header(FILE *fin, struct npy_info* ni) else if (0 == strcmp(desc, "c16")) type = IIO_TYPE_DOUBLE; else return fprintf(stderr, "IIO ERROR: unrecognized npy type \"%s\"\n", desc), 0; - if (*desc == 'c') ni->dims[ni->ndims-1] *= 2; // 1 complex = 2 reals + if (*desc == 'c') ni->dims[ni->ndims++] = 2; // 1 complex = 2 reals strncpy(ni->desc, descr, 10); ni->type = type; diff --git a/external/imscript/plambda.c b/external/imscript/plambda.c index 4fbb91a9..f833120f 100644 --- a/external/imscript/plambda.c +++ b/external/imscript/plambda.c @@ -259,9 +259,9 @@ // #defines {{{1 -#define PLAMBDA_MAX_TOKENS 513 +#define PLAMBDA_MAX_TOKENS 213 #define PLAMBDA_MAX_VARLEN 0x100 -#define PLAMBDA_MAX_PIXELDIM 600 +#define PLAMBDA_MAX_PIXELDIM 108 #define PLAMBDA_MAX_MAGIC 42 diff --git a/src/ImageCollection.cpp b/src/ImageCollection.cpp index 7d7c8dcc..bd0455d4 100644 --- a/src/ImageCollection.cpp +++ b/src/ImageCollection.cpp @@ -201,11 +201,13 @@ class NumpyVideoImageProvider : public VideoImageProvider { void* data = malloc(framesize); if (fread(data, 1, framesize, file) != framesize) { onFinish(makeError("npy: couldn't read frame")); + } else { + // convert to float + float* pixels = npy_convert_to_float(data, w * h * d, ni.type); + auto image = std::make_shared(pixels, w, h, d); + onFinish(image); } - // convert to float - float* pixels = npy_convert_to_float(data, w * h * d, ni.type); - auto image = std::make_shared(pixels, w, h, d); - onFinish(image); + fclose(file); } }; @@ -218,7 +220,7 @@ class NumpyVideoImageCollection : public VideoImageCollection { FILE* file = fopen(filename.c_str(), "r"); if (!npy_read_header(file, &ni)) { fprintf(stderr, "[npy] error while loading header\n"); - exit(1); + //exit(1); } fclose(file); diff --git a/src/ImageProvider.cpp b/src/ImageProvider.cpp index ab978836..1457f059 100644 --- a/src/ImageProvider.cpp +++ b/src/ImageProvider.cpp @@ -42,7 +42,17 @@ void GDALFileImageProvider::progress() int w = g->GetRasterXSize(); int h = g->GetRasterYSize(); int d = g->GetRasterCount(); - float* pixels = (float*) malloc(sizeof(float) * w * h * d); + int tf = 1; + GDALDataType asktype = GDT_Float32; + if (d == 1) { + GDALRasterBand* band = g->GetRasterBand(1); + GDALDataType type = band->GetRasterDataType(); + if (GDALDataTypeIsComplex(type)) { + asktype = GDT_CFloat32; + tf = 2; + } + } + float* pixels = (float*) malloc(sizeof(float) * w * h * d * tf); GDALRasterIOExtraArg args; INIT_RASTERIO_EXTRA_ARG(args); args.pfnProgress = [](double d, const char*, void* data){ @@ -50,9 +60,10 @@ void GDALFileImageProvider::progress() return 1; }; args.pProgressData = this; - CPLErr err = g->RasterIO(GF_Read, 0, 0, w, h, pixels, w, h, GDT_Float32, d, - NULL, sizeof(float)*d, sizeof(float)*w*d, sizeof(float), + CPLErr err = g->RasterIO(GF_Read, 0, 0, w, h, pixels, w, h, asktype, d, + NULL, sizeof(float)*d*tf, sizeof(float)*w*d*tf, sizeof(float)*tf, &args); + d *= tf; GDALClose(g); if (err != CE_None) { diff --git a/src/Window.cpp b/src/Window.cpp index 55894204..9e8dd771 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -374,6 +374,10 @@ void Window::display() } if (ImGui::IsWindowFocused()) { + if (isKeyDown("shift") && isKeyPressed("q")) { + opened = false; + relayout(false); + } if (isKeyPressed(" ")) { this->index = (this->index + 1) % sequences.size(); } @@ -751,7 +755,24 @@ void Window::displaySequence(Sequence& seq) } } - if (!ImGui::GetIO().WantCaptureKeyboard && (delta.x || delta.y) && isKeyDown("shift")) { + // keep track of the cursor when we started shifting + static bool isShifting = false; + static ImVec2 shiftPos; + static bool isFar; + if (isKeyDown("shift")) { + if (!isShifting) { + shiftPos = ImGui::GetMousePos(); + isShifting = true; + isFar = false; + } + } else { + isShifting = false; + } + if (!isFar) { + ImVec2 disp(shiftPos - ImGui::GetMousePos()); + isFar = std::hypot(disp.x, disp.y) > 100; + } + if (!ImGui::GetIO().WantCaptureKeyboard && (delta.x || delta.y) && isKeyDown("shift") && isFar) { ImRect clip = getClipRect(); ImVec2 cursor = ImGui::GetMousePos() - clip.Min; ImVec2 pos = view->window2image(cursor, displayarea.getCurrentSize(), winSize, factor); diff --git a/src/main.cpp b/src/main.cpp index 0e5b1f14..3718673e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -542,7 +542,7 @@ int main(int argc, char* argv[]) } } - if (isKeyPressed("q")) { + if (!isKeyDown("shift") && !isKeyDown("alt") && !isKeyDown("control") && isKeyPressed("q")) { done = true; } @@ -808,6 +808,7 @@ void help() ImGui::Spacing(); T("Shortcuts"); B(); T("num: show the nth window (useful with fullscreen layout)"); + B(); T("shift+q: close the current window"); B(); T("tab/shift+tab: cycle through windows"); B(); T("space/backspace: display the next/previous image attached to the window"); B(); T("ctrl+l/shift+ctrl+l: cycle through layouts");