Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
kidanger committed Mar 16, 2021
2 parents 9a9a582 + dd8398e commit d64bf56
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 32 deletions.
38 changes: 23 additions & 15 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

8 changes: 4 additions & 4 deletions external/iio/iio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion external/iio/npy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions external/imscript/plambda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
12 changes: 7 additions & 5 deletions src/ImageCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Image>(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<Image>(pixels, w, h, d);
onFinish(image);
fclose(file);
}
};

Expand All @@ -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);

Expand Down
17 changes: 14 additions & 3 deletions src/ImageProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,28 @@ 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){
((GDALFileImageProvider*) data)->df = d;
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) {
Expand Down
23 changes: 22 additions & 1 deletion src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ int main(int argc, char* argv[])
}
}

if (isKeyPressed("q")) {
if (!isKeyDown("shift") && !isKeyDown("alt") && !isKeyDown("control") && isKeyPressed("q")) {
done = true;
}

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit d64bf56

Please sign in to comment.