java3d
  1. java3d
  2. JAVA3D-573

If I display one Bufferedimage it is ok for images with 2048 height or width. But with 4096 width or 4096 height ... image is croped.....

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: not determined
    • Component/s: j3d-core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      573
    • Status Whiteboard:
      Hide

      incomplete

      Show
      incomplete

      Description

      [First issue I ever post... ]
      I stumbled into a strange (bad) behavior in displaying a BufferedImage with help
      of Texture2D, into a Shape3D. Maybe it is not a defect. But I really check my
      code and ... it looks really ok from my point of Vue. So why not a defct with
      large textures....

      If size of Image has :
      -Width 2048 or less (modulo 2^n )
      -height 2048 or less(.... )
      ==> it displays my image inside a standard suqare (shape3D)

      BUT if I double image with or height :

      • for example Width 2*2048= 4096
      • or height of 4096
        ==> it displays my image but Cropped, as if it were incapable of displaying the
        siez extension of the image.

      If size of Image has :
      -Width 2048 or less (modulo 2^n )
      -height 2048 or less(.... )
      ==> it displays my image inside a standard suqare (shape3D)

      Here is the code I used:
      -----------------------------
      A) important lines :
      // .......
      // 2) Définition de la NOUVELLE image Texture:
      BufferedImage newImgTexture;
      newImgTexture = uneZoneMurP.getImgTexture();
      TextureLoader newTextureLoader = new TextureLoader(newImgTexture);
      ImageComponent2D newImageComp2D = newTextureLoader.getImage();

      // 3) On remplace sa Texture:
      Texture2D aNewTexture2D = new Texture2D(Texture2D.BASE_LEVEL,
      Texture.RGB, newImageComp2D.getWidth(), newImageComp2D.getHeight());
      aNewTexture2D.setImage(0, newImageComp2D);
      //....

      -----------------------------
      A) Full codes :

      Shape3D unLosangeMurAvantActuel = (Shape3D) murBG.getChild(0);

      Appearance appearanceActuelle =
      unLosangeMurAvantActuel.getAppearance();
      Texture2D texture2dActuelle = (Texture2D)
      appearanceActuelle.getTexture();
      int widthActuelle = texture2dActuelle.getWidth();
      int heightActuelle = texture2dActuelle.getHeight();

      // 2) Définition de la NOUVELLE image Texture:
      BufferedImage newImgTexture;
      newImgTexture = uneZoneMurP.getImgTexture();
      TextureLoader newTextureLoader = new TextureLoader(newImgTexture);
      ImageComponent2D newImageComp2D = newTextureLoader.getImage();

      // 3) On remplace sa Texture:
      Texture2D aNewTexture2D = new Texture2D(Texture2D.BASE_LEVEL,
      Texture.RGB, newImageComp2D.getWidth(), newImageComp2D.getHeight());
      aNewTexture2D.setImage(0, newImageComp2D);

      aNewTexture2D.setCapability(Appearance.ALLOW_TEXTURE_READ);
      aNewTexture2D.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
      aNewTexture2D.setCapability(Texture.ALLOW_IMAGE_WRITE);
      aNewTexture2D.setCapability(Texture.ALLOW_SIZE_READ);

      // Nous sommes obligé (à priori de changé d'appearance:
      Appearance appNelle = new Appearance();

      appNelle.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);

      appNelle.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
      appNelle.setCapability(Appearance.ALLOW_TEXTURE_READ);
      appNelle.setCapability(Appearance.ALLOW_TEXTURE_WRITE);

      //appNelle.setTexture(aNewTexture2D);
      TextureAttributes textAttr = new TextureAttributes();
      textAttr.setTextureMode(TextureAttributes.REPLACE);
      //************
      // ** Gestion d'une transparence.
      TransparencyAttributes transparencyAttr = new
      TransparencyAttributes();
      transparencyAttr.setTransparency(0.0f /0.5f/ /1f/);

      transparencyAttr.setCapability(TransparencyAttributes.ALLOW_VALUE_READ);

      transparencyAttr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);

      transparencyAttr.setTransparencyMode(TransparencyAttributes.NICEST);
      appNelle.setTransparencyAttributes(transparencyAttr);
      //************
      appNelle.setTexture(aNewTexture2D);
      appNelle.setTextureAttributes(textAttr);
      Color3f ambientColour = new Color3f(1.0f, 0.0f, 0.0f);
      //Color3f ambientColour = new Color3f(1.0f, 1.0f, 1.0f);
      Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);
      Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);
      Color3f diffuseColour = new Color3f(1.0f, 0.0f, 0.0f);
      //Color3f diffuseColour = new Color3f(1.0f, 1.0f, 1.0f);
      float shininess = 20.0f;
      appNelle.setMaterial(new Material(ambientColour, emissiveColour,
      diffuseColour, specularColour, shininess));

      unLosangeMurAvantActuel.setAppearance(appNelle);

        Activity

        Hide
        kcr added a comment -

        This is probably not a bug. Graphics systems have an upper limit on the size of
        textures, which is typically 2K x 2K or 4K x 4K for most systems. Use
        Canvas3D.queryProperties to discover the limit for your system. You can run the
        QueryProperties example program from the following page:

        https://j3d-webstart.dev.java.net/test/

        It will display the graphics capabilities of your system.

        Marking issue as "incomplete".

        Show
        kcr added a comment - This is probably not a bug. Graphics systems have an upper limit on the size of textures, which is typically 2K x 2K or 4K x 4K for most systems. Use Canvas3D.queryProperties to discover the limit for your system. You can run the QueryProperties example program from the following page: https://j3d-webstart.dev.java.net/test/ It will display the graphics capabilities of your system. Marking issue as "incomplete".
        Hide
        tmilard added a comment -

        Yes Kevin you are right.
        I check and my limit is .. 2048 K
        Just the limit I "discovered" in the bug !

        I closed the bug to "resolved".

        Ps: Just one idiotic idea.
        Would it not be one securisation if in t

        Show
        tmilard added a comment - Yes Kevin you are right. I check and my limit is .. 2048 K Just the limit I "discovered" in the bug ! I closed the bug to "resolved". Ps: Just one idiotic idea. Would it not be one securisation if in t
        Hide
        tmilard added a comment -

        (issue closed)==>
        reminder for all :

        Issue : When you place a Buffered Image and find it cropped in the 3D display,

        Example Code [
        //--------------
        BufferedImage newImgTexture;
        newImgTexture = XXXX.getOneBufferedImage();
        TextureLoader newTextureLoader = new TextureLoader(newImgTexture);
        ImageComponent2D newImageComp2D = newTextureLoader.getImage();
        Texture2D aNewTexture2D = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB,
        newImageComp2D.getWidth(), newImageComp2D.getHeight());
        aNewTexture2D.setImage(0, newImageComp2D);
        //--------------
        ]

        Solution : There is 99,9% chance your image has a width or height GREATER than
        your graphic card (or dirver I suppose) support.
        just compare your image width and height with java3D "textureWidthMax" and
        "textureHeightMax" parameters.
        Map yourCardMapProperties = (your_Canvas3D_instance).queryProperties();
        int maxWidthOfYourCard = yourCardMapProperties.get("textureWidthMax");
        int maxHeightOfYourCard = yourCardMapProperties.get("textureHeightMax");
        if ((newImgTexture.getWidth() > maxWidthOfYourCard ) ||
        (newImgTexture.getHeight() > maxHeightOfYourCard ) )

        { System.out.println("He he he, bloody hell, if say your graphic card was a chinese lady your image would surely me a black man. Stopit or I will crop your ... "); }

        One last small thinking : Why not put this test in the API code with one
        exception like "TextureTooLargeForGraphicCardException". Is it a problem of
        performance issue.Or other ?

        Show
        tmilard added a comment - (issue closed)==> reminder for all : Issue : When you place a Buffered Image and find it cropped in the 3D display, Example Code [ //-------------- BufferedImage newImgTexture; newImgTexture = XXXX.getOneBufferedImage(); TextureLoader newTextureLoader = new TextureLoader(newImgTexture); ImageComponent2D newImageComp2D = newTextureLoader.getImage(); Texture2D aNewTexture2D = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB, newImageComp2D.getWidth(), newImageComp2D.getHeight()); aNewTexture2D.setImage(0, newImageComp2D); //-------------- ] Solution : There is 99,9% chance your image has a width or height GREATER than your graphic card (or dirver I suppose) support. just compare your image width and height with java3D "textureWidthMax" and "textureHeightMax" parameters. Map yourCardMapProperties = (your_Canvas3D_instance).queryProperties(); int maxWidthOfYourCard = yourCardMapProperties.get("textureWidthMax"); int maxHeightOfYourCard = yourCardMapProperties.get("textureHeightMax"); if ((newImgTexture.getWidth() > maxWidthOfYourCard ) || (newImgTexture.getHeight() > maxHeightOfYourCard ) ) { System.out.println("He he he, bloody hell, if say your graphic card was a chinese lady your image would surely me a black man. Stopit or I will crop your ... "); } One last small thinking : Why not put this test in the API code with one exception like "TextureTooLargeForGraphicCardException". Is it a problem of performance issue.Or other ?

          People

          • Assignee:
            java3d-issues
            Reporter:
            tmilard
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: