octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55436] Add support for more types for image's


From: Guillaume
Subject: [Octave-bug-tracker] [bug #55436] Add support for more types for image's cdata
Date: Thu, 10 Jan 2019 06:05:44 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

URL:
  <https://savannah.gnu.org/bugs/?55436>

                 Summary: Add support for more types for image's cdata
                 Project: GNU Octave
            Submitted by: gyom
            Submitted on: Thu 10 Jan 2019 11:05:43 AM UTC
                Category: Plotting with OpenGL
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Feature Request
                  Status: None
             Assigned to: None
         Originator Name: Guillaume
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

Currently, only a few data types are supported with image() and imagesc():


octave> figure,imagesc(int16(rand(32)))
warning: unsupported type for cdata (= int16 matrix).  Valid types are uint8,
uint16, double, single, and bool.


Following comment #3 in bug #46933, I made the following change in
libinterp/corefcn/graphics.cc:


--- a/libinterp/corefcn/graphics.cc     Wed Jan 09 19:10:38 2019 -0800
+++ b/libinterp/corefcn/graphics.cc     Thu Jan 10 10:53:01 2019 +0000
@@ -1015,8 +1015,20 @@
 
   if (cdata.is_uint8_type ())
     CONVERT_CDATA_1 (uint8NDArray, uint8_, false);
+  if (cdata.is_int8_type ())
+    CONVERT_CDATA_1 (int8NDArray, int8_, false);
   else if (cdata.is_uint16_type ())
     CONVERT_CDATA_1 (uint16NDArray, uint16_, false);
+  else if (cdata.is_int16_type ())
+    CONVERT_CDATA_1 (int16NDArray, int16_, false);
+  else if (cdata.is_uint32_type ())
+    CONVERT_CDATA_1 (uint32NDArray, uint32_, false);
+  else if (cdata.is_int32_type ())
+    CONVERT_CDATA_1 (int32NDArray, int32_, false);
+  else if (cdata.is_uint64_type ())
+    CONVERT_CDATA_1 (uint64NDArray, uint64_, false);
+  else if (cdata.is_int64_type ())
+    CONVERT_CDATA_1 (int64NDArray, int64_, false);
   else if (cdata.is_double_type ())
     CONVERT_CDATA_1 (NDArray, , true);
   else if (cdata.is_single_type ())
@@ -1027,7 +1039,7 @@
     {
       // Don't throw an error; leads to an incomplete FLTK object (bug
#46933).
       warning ("unsupported type for cdata (= %s).  "
-               "Valid types are uint8, uint16, double, single, and bool.",
+               "Valid types are uint8, int8, uint16, int16, uint32, int32,
uint64, int64, double, single, and bool.",
                cdata.type_name ().c_str ());
       a = NDArray (dv, 0);  // return 0 instead
     }


and while it then works with, eg, int16, there is still an error for other
types:


octave> figure,imagesc(int32(rand(32)))
error: invalid value for array property "cdata"
error: __go_image__: unable to create graphics handle
error: called from
    image>__img__ at line 205 column 5
    image at line 125 column 10
    imagesc at line 101 column 12


so I also modified libinterp/corefcn/graphics.in.h:


--- a/libinterp/corefcn/graphics.in.h   Wed Jan 09 19:10:38 2019 -0800
+++ b/libinterp/corefcn/graphics.in.h   Thu Jan 10 11:03:57 2019 +0000
@@ -4556,8 +4556,13 @@
       cdata.add_constraint ("single");
       cdata.add_constraint ("logical");
       cdata.add_constraint ("uint8");
+      cdata.add_constraint ("int8");
       cdata.add_constraint ("uint16");
       cdata.add_constraint ("int16");
+      cdata.add_constraint ("uint32");
+      cdata.add_constraint ("int32");
+      cdata.add_constraint ("uint64");
+      cdata.add_constraint ("int64");
       cdata.add_constraint ("real");
       cdata.add_constraint (dim_vector (-1, -1));
       cdata.add_constraint (dim_vector (-1, -1, 3));


It does seem to work for me but I wonder if it doesn't create problems
elsewhere as it was not implemented in the first place.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55436>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]