Messages by freesailor

8 topics, 29 messages
Kuix technical support » I need the Drop Down Component....

I think a popup menu with choiceradiogroup would be better than a separate screen, even if the screen is small.

So why not give it a try and allow to have both optins (new screen and popup over screen)?

Kuix technical support » widget size when it is not visible

Good news.

and I think to put them back to screen is to set visible to true.

Kuix technical support » widget size when it is not visible

What I want to achieve is create a tree like list.

list items are like this :   father - child

father line : father - child is invisible

child line   : father is invisible - child

and here i would like the father to free its space and hence i get :

                                 father

                                                     child 1

                                                     child 2

 

Kuix technical support » widget size when it is not visible

is there any way to make a widget width =0 when it's not visible.

I need to align 2 widgets in the same row, and want widget2 to have all the available space when widget1 is not visible.

Kuix technical support » feature request : Picture.SetImage(Image)

No, I didnt. I found the code here http://www.mobilegd.com/index.php?option=com_smf&Itemid=74&topic=34.0

They are tyring to optimize it.

Kuix technical support » feature request : Picture.SetImage(Image)

Great news.

While waiting for the next release, I created a new Picture like widget that accepts loading memory images and it saves a lot of time and efforts.

I also experienced the following function resizeImage and it woks :

Use it like this

MyResizedImage = resizeImage(MyBaseImage, newWidth, newHeigth, 0)

here is the code :

   // fixed point constants
   private static final int FP_SHIFT = 13;
   private static final int FP_ONE = 1 << FP_SHIFT;
   private static final int FP_HALF = 1 << (FP_SHIFT - 1);
  
   // resampling modes - valid values for the mode parameter of resizeImage()
   // any other value will default to MODE_BOX_FILTER because of the way the conditionals are set in resizeImage()
   public static final int MODE_POINT_SAMPLE = 0;
   public static final int MODE_BOX_FILTER = 1;
  
   /**
    * getPixels
    * Wrapper for pixel grabbing techniques.
    * I separated this step into it's own function so that other APIs (Nokia, Motorola, Siemens, etc.) can
    * easily substitute the MIDP 2.0 API (Image.getRGB()).
    * @param src The source image whose pixels we are grabbing.
    * @return An int array containing the pixels in 32 bit ARGB format.
    */
   public static int[] getPixels(Image src) {
      int w = src.getWidth();
      int h = src.getHeight();
      int[] pixels = new int[w * h];
      src.getRGB(pixels,0,w,0,0,w,h);
      return pixels;
   }
  
   /**
    * drawPixels
    * Wrapper for pixel drawing function.
    * I separated this step into it's own function so that other APIs (Nokia, Motorola, Siemens, etc.) can
    * easily substitute the MIDP 2.0 API (Image.createRGBImage()).
    * @param pixels int array containing the pixels in 32 bit ARGB format.
    * @param w The width of the image to be created.
    * @param h The height of the image to be created. This parameter is actually superfluous, because it
    * must equal pixels.length / w.
    * @return The image created from the pixel array.
    */
   public static Image drawPixels(int[] pixels, int w, int h) {
      return Image.createRGBImage(pixels,w,h,true);
   }
  
   /**
    * resizeImage
    * Gets a source image along with new size for it and resizes it.
    * @param src The source image.
    * @param destW The new width for the destination image.
    * @param destH The new heigth for the destination image.
    * @param mode A flag indicating what type of resizing we want to do. It currently supports two type:
    * MODE_POINT_SAMPLE - point sampled resizing, and MODE_BOX_FILTER - box filtered resizing (default).
    * @return The resized image.
    */
   public static Image resizeImage(Image src, int destW, int destH, int mode) {
      int srcW = src.getWidth();
      int srcH = src.getHeight();
     
      // create pixel arrays
      int[] destPixels = new int[destW * destH]; // array to hold destination pixels
      int[] srcPixels = getPixels(src); // array with source's pixels
     
      if (mode == MODE_POINT_SAMPLE) {
         // simple point smapled resizing
         // loop through the destination pixels, find the matching pixel on the source and use that
         for (int destY = 0; destY < destH; ++destY) {
            for (int destX = 0; destX < destW; ++destX) {
               int srcX = (destX * srcW) / destW;
               int srcY = (destY * srcH) / destH;
               destPixels[destX + destY * destW] = srcPixels[srcX + srcY * srcW];
            }
         }
      }
      else {
         // precalculate src/dest ratios
         int ratioW = (srcW << FP_SHIFT) / destW;
         int ratioH = (srcH << FP_SHIFT) / destH;
        
         int[] tmpPixels = new int[destW * srcH]; // temporary buffer for the horizontal resampling step
        
         // variables to perform additive blending
         int argb; // color extracted from source
         int a, r, g, b; // separate channels of the color
         int count; // number of pixels sampled for calculating the average
        
         // the resampling will be separated into 2 steps for simplicity
         // the first step will keep the same height and just stretch the picture horizontally
         // the second step will take the intermediate result and stretch it vertically
        
         // horizontal resampling
         for (int y = 0; y < srcH; ++y) {
            for (int destX = 0; destX < destW; ++destX) {
               count = 0; a = 0; r = 0; b = 0; g = 0; // initialize color blending vars
               int srcX = (destX * ratioW) >> FP_SHIFT; // calculate beginning of sample
               int srcX2 = ((destX + 1) * ratioW) >> FP_SHIFT; // calculate end of sample
              
               // now loop from srcX to srcX2 and add up the values for each channel
               do {
                  argb = srcPixels[srcX + y * srcW];
                  a += ((argb & 0xff000000) >> 24); // alpha channel
                  r += ((argb & 0x00ff0000) >> 16); // red channel
                  g += ((argb & 0x0000ff00) >> 8); // green channel
                  b += (argb & 0x000000ff); // blue channel
                  ++count; // count the pixel
                  ++srcX; // move on to the next pixel
               }
               while (srcX <= srcX2 && srcX + y * srcW < srcPixels.length);
              
               // average out the channel values
               a /= count;
               r /= count;
               g /= count;
               b /= count;
              
               // recreate color from the averaged channels and place it into the temporary buffer
               tmpPixels[destX + y * destW] = ((a << 24) | (r << 16) | (g << 8) | b);
            }
         }
        
         // vertical resampling of the temporary buffer (which has been horizontally resampled)
         System.out.println("Vertical resampling...");
         for (int x = 0; x < destW; ++x) {
            for (int destY = 0; destY < destH; ++destY) {
               count = 0; a = 0; r = 0; b = 0; g = 0; // initialize color blending vars
               int srcY = (destY * ratioH) >> FP_SHIFT; // calculate beginning of sample
               int srcY2 = ((destY + 1) * ratioH) >> FP_SHIFT; // calculate end of sample
              
               // now loop from srcY to srcY2 and add up the values for each channel
               do {
                  argb = tmpPixels[x + srcY * destW];
                  a += ((argb & 0xff000000) >> 24); // alpha channel
                  r += ((argb & 0x00ff0000) >> 16); // red channel
                  g += ((argb & 0x0000ff00) >> 8); // green channel
                  b += (argb & 0x000000ff); // blue channel
                  ++count; // count the pixel
                  ++srcY; // move on to the next pixel
               }
               while (srcY <= srcY2 && x + srcY * destW < tmpPixels.length);
              
               // average out the channel values
               a /= count; a = (a > 255) ? 255 : a;
               r /= count; r = (r > 255) ? 255 : r;
               g /= count; g = (g > 255) ? 255 : g;
               b /= count; b = (b > 255) ? 255 : b;
              
               // recreate color from the averaged channels and place it into the destination buffer
               destPixels[x + destY * destW] = ((a << 24) | (r << 16) | (g << 8) | b);
            }
         }
      }
     
      // return a new image created from the destination pixel buffer
      return drawPixels(destPixels,destW,destH);
   } 
 
 
 
 

Kuix technical support » feature request : Picture.SetImage(Image)

What I need is to set the image for Picture from png in memory.

My app loads pngs from files as Image object and apply some transformations to that Image (for example fading) and then I need to assign the resulting Image again to my Picture widget.

Any help.

Kuix technical support » feature request : Picture.SetImage(Image)

Hi,

I develop a graphix midlet, and do lot of work on images and need to convert them to byte[] so I can use in kuix.

The problem is I dont find any working code to export Image to byte[], I tried a lot but none works.

I think it would be easier to rewrite the Picture class in order to accept image settings directly :

public static SetImage(Image image)

{

 this.image = image;

.....

}

 

Kuix technical support » bug report : screen latency

Hi, I load a screen and then try to get some widget size, it returns 0

MyScreen.SetCurrent()

Widget wid = MyScreen.getWidget("Wid");
MyMidlet.getDefault().alert(Integer.toString(wid.getWidth()), KuixConstants.ALERT_OK);

After that immediately, I run the same code by clicking some button, and it returns a valid width.

Is that a bug or I am missing something that forces the screen to invalidate it self after SetCurrent

Kuix technical support » Container attributes

Hi, in fact Mycontainer.getwidth returns 0, despite its visible and filling the screen!

Kuix technical support » Container attributes

Hi, I'am trying to get a container Widget attributes using its id, but at runtime when I access container.getwidth it throws an exception.

Kuix technical support » escaping from long lists

Hi it worked as you told i can now change the focus to a widget, but  I didn't understand well  how to use the casting technique you described for aruments[0].

Kuix technical support » escaping from long lists

When using long lists it may be useful to let the user escape from the list to an other widget on the screen without being forced to walk through all the items of the list.

for example the KuixCanvas.UP_KEY and DOWN_KEY can be used to navigate the list's items and SOFT_KEY_LEFT and SOFT_KEY_RIGHT can be used to jump out of the list.

Is there any simple way to do this, without using focusmanager etc.?

Kuix technical support » [asking] dynamic images with dataProvider

Hi, please have a look at the picture widget.

there you will find this :

public Picture setImageData(byte[] imageData) {
        if (imageData == null) {
            image = null;
        } else {
            image = Image.createImage(imageData, 0, imageData.length);
        }
        invalidate();
        return this;
    }
So, you can create the the image you want and set it to the picture widget with java code, not in the xml file.

If you want to set the image for a certain picture you have in your xml, just give it an id and then access it form java code.

<picture id="Mypicture"></picture>

and then access to your picture widget by its id, and then set imagedata.

 

Kuix technical support » resizing widgets

But some popupbox used in splash demo can display a picture with zoom.