×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    80

    Detect all image file in a folder

    I want to createImage() for all image file inside a folder. How do i know how many images are there in a folder?

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Detect all image file in a folder

    Quote Originally Posted by fecxelmin View Post
    I want to createImage() for all image file inside a folder. How do i know how many images are there in a folder?
    Hello,

    Nope, You can not get the directly the number of images in the folder.You have to use the JSR 75, FileConnection API.

    But in your case I guess you are trying to access the number of the images in folder which is burned inside the jar file.If this is the case then this can not be done.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Detect all image file in a folder

    First you have to browse to that file using file connection API then,
    you have to check the file extension.After that only you are able to know wheather that file is a image file or not.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Detect all image file in a folder

    You cant use craeteInage() for all files in the folder, it can be done only for images inside the JAR in res folder.

    thanks,
    ~Amitabh

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Detect all image file in a folder

    Quote Originally Posted by im2amit View Post
    You cant use craeteInage() for all files in the folder, it can be done only for images inside the JAR in res folder.

    thanks,
    ~Amitabh
    We can browse the image file from a particular folder (e.g image folder) of the device and create the image based on the device screen width and height for displaying the full image(if the image is larger than the device size).

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Detect all image file in a folder

    Quote Originally Posted by ajitkumar26 View Post
    We can browse the image file from a particular folder (e.g image folder) of the device and create the image based on the device screen width and height for displaying the full image(if the image is larger than the device size).
    What if the image is of size 10x10?
    what if I would like to draw the multiple image at the same time?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Detect all image file in a folder

    Quote Originally Posted by raj_J2ME View Post
    What if the image is of size 10x10?
    what if I would like to draw the multiple image at the same time?
    If the image is of size 10x10 then no need to do anything only draw on the screen.
    draw the multiple image at the same time means on a single screen or what?

  8. #8
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    80

    Re: Detect all image file in a folder

    Quote Originally Posted by ajitkumar26 View Post
    First you have to browse to that file using file connection API then,
    you have to check the file extension.After that only you are able to know wheather that file is a image file or not.
    Can you teach me in details on the file connection API? Coding from you will be most helpful.

  9. #9
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    80

    Re: Detect all image file in a folder

    Quote Originally Posted by ajitkumar26 View Post
    We can browse the image file from a particular folder (e.g image folder) of the device and create the image based on the device screen width and height for displaying the full image(if the image is larger than the device size).
    how do i createImage according to device screen width and height?
    Below are the createImage from API:
    createImage(byte[] imageData, int imageOffset, int imageLength)
    createImage(Image source)
    createImage(Image image, int x, int y, int width, int height, int transform)
    createImage(java.io.InputStream stream)
    createImage(int width, int height)
    createImage(String name)

    I dont see one that can createImage according to device screen width and height. correct me if im wrong. the most possible one is: createImage(int width, int height) but this one create mutable image.

    Anyone can help? or suggest a way to display image larger than device screen.

  10. #10
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Detect all image file in a folder

    Quote Originally Posted by fecxelmin View Post
    I want to createImage() for all image file inside a folder. How do i know how many images are there in a folder?
    I guess that was the topic of your initial post. Kindly read the complete discussion.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  11. #11
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Detect all image file in a folder

    Quote Originally Posted by fecxelmin View Post
    Can you teach me in details on the file connection API? Coding from you will be most helpful.

    In the Netbeans Samples for JavaME there is a sample project called "PDAP Demo".
    Just go through that you will be able to know the implementation of file connection API.

    Thanks & Regards,
    Ajit

  12. #12
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Detect all image file in a folder

    Quote Originally Posted by fecxelmin View Post
    how do i createImage according to device screen width and height?
    Below are the createImage from API:
    createImage(byte[] imageData, int imageOffset, int imageLength)
    createImage(Image source)
    createImage(Image image, int x, int y, int width, int height, int transform)
    createImage(java.io.InputStream stream)
    createImage(int width, int height)
    createImage(String name)

    I dont see one that can createImage according to device screen width and height. correct me if im wrong. the most possible one is: createImage(int width, int height) but this one create mutable image.

    Anyone can help? or suggest a way to display image larger than device screen.

    First you have to create image using one of the above createImage method available in the API.
    Then pass the created image to the following method and desired width and height as parameter you will get the corresponding image of having desired width and height.

    The code snippet is for the above is given below:
    /**
    * Changes size of bitmap.
    * @param sourceImage source image.
    * @param newWidth width of new image.
    * @param newHeight height of new image.
    * @return scaled image.
    */
    public static Image scaleImage(Image sourceImage, int newWidth, int newHeight) {
    //Remember image size.
    int oldWidth = sourceImage.getWidth();
    int oldHeight = sourceImage.getHeight();
    //Create buffer for input image.
    int[] inputData = new int[oldWidth * oldHeight];
    //Fill it with image data.
    sourceImage.getRGB(inputData, 0, oldWidth, 0, 0, oldWidth, oldHeight);
    //Create buffer for output image.
    int[] outputData = new int[newWidth * newHeight];
    int YD = (oldHeight / newHeight - 1) * oldWidth;
    int YR = oldHeight % newHeight;
    int XD = oldWidth / newWidth;
    int XR = oldWidth % newWidth;
    //New image buffer offset.
    int outOffset = 0; //Source image buffer offset.
    int inOffset = 0;
    for (int y = newHeight, YE = 0; y > 0; y--) {
    for (int x = newWidth, XE = 0; x > 0; x--) {
    outputData[outOffset++] = inputData[inOffset];
    inOffset += XD;
    XE += XR;
    if (XE >= newWidth) {
    XE -= newWidth;
    inOffset++;
    }
    }
    inOffset += YD;
    YE += YR;
    if (YE >= newHeight) {
    YE -= newHeight;
    inOffset += oldWidth;
    }
    }
    return Image.createRGBImage(outputData, newWidth, newHeight, false);
    }

    Thanks & Regards,
    Ajit

Similar Threads

  1. MBM image is not found
    By tamhanna in forum Symbian
    Replies: 14
    Last Post: 2009-04-20, 12:44
  2. [split] mbm build error
    By mando222 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2009-03-29, 12:32
  3. Contacts fields order??
    By timatima in forum Symbian
    Replies: 1
    Last Post: 2007-06-08, 13:51
  4. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×