Skip to content

Dimension swapped when creating image from 2d array #2

@leonardtsai

Description

@leonardtsai

Tested on 12.20 FLTK version.

Document tells me the first dimension is y and 2nd dimension is x. But I follow that instruction, ex. dim a(479, 639), the result is wrong. dim a(639, 479) will be correct, but when setting pixel, you have to put y dimension in the first position, i.e. a(479, 639) is the right bottom pixel.

After looking into src/ui/image.cpp, I guess the problem located at ImageBuffer *load_image(var_t *var).

line 178,

} else if (var->type == V_ARRAY && v_maxdim(var) == 2) {
int w = ABS(v_lbount(var, 0) - v_ubound(var, 0)) + 1 // 1st dimension is used as width
int h = ABS(v_lbount(var, 1) - v_ubound(var, 1)) + 1 // 2nd dimension is used as height

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions