Thread: Load item inventory icons from sprites!

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30
  1. #11  
    Registered Member Buddie's Avatar
    Join Date
    Apr 2009
    Posts
    76
    Thanks given
    0
    Thanks received
    0
    Rep Power
    8
    Very nice, good work on this
    Reply With Quote  
     

  2. #12  
    Apocalyptism
    Harry's Avatar
    Join Date
    Apr 2007
    Posts
    3,783
    Thanks given
    594
    Thanks received
    1,833
    Rep Power
    2934
    Going to look into why when you drag the item, the white loses its transparency. Guessing its to do with drawsprite1
    ~ Harry
    Please bear this in mind when hearing the word 'soon' from a software programmer.

    As coding software generally takes thousands of years, software programmers have developed a natural adaptation to this in the form of an altered perception of the flow of time.

    Due to this, the word 'soon' when uttered by a programmer should be taken to mean 'a very, very long time from now' in the terminology used by common human specimens who have not developed such an adaptation.
    knowledge can be taught, but passion cannot.
    It's better to create something that others criticise than to create nothing and criticise others.
    Reply With Quote  
     

  3. #13  
    Registered Member Aggi's Avatar
    Join Date
    Oct 2007
    Posts
    687
    Thanks given
    203
    Thanks received
    49
    Rep Power
    111
    great job bloodisle
    Reply With Quote  
     

  4. #14  
    35518
    Guest
    Quote Originally Posted by Blood Isle View Post
    Going to look into why when you drag the item, the white loses its transparency. Guessing its to do with drawsprite1
    It's because drawSprite1 doesn't make white transparent, but drawSprite does. Just use this when you're loading the sprites, before the pixelgrabber.

    Code:
    image = makeColorTransparent(image, new Color(0, 0, 0, 0));
    Code:
        public static Image makeColorTransparent (Image im, final Color color) {
            ImageFilter filter = new RGBImageFilter() {
                public int markerRGB = color.getRGB() | 0xFF000000;
                public final int filterRGB(int x, int y, int rgb) {
                    if ( ( rgb | 0xFF000000 ) == markerRGB ) {
                        return 0x00FFFFFF & rgb;
                    } else {
                    return rgb;
                    }
                }
            };
            ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
            return Toolkit.getDefaultToolkit().createImage(ip);
        }
    Reply With Quote  
     

  5. #15  
    Pur3z is back!
    tehGanjaman's Avatar
    Join Date
    Jul 2008
    Age
    28
    Posts
    2,871
    Thanks given
    3,380
    Thanks received
    109
    Rep Power
    502
    verry nice :cookie:
    Reply With Quote  
     

  6. #16  
    Banned

    Join Date
    Jun 2008
    Age
    26
    Posts
    811
    Thanks given
    302
    Thanks received
    36
    Rep Power
    0
    thanks dont think ill use but i might
    Reply With Quote  
     

  7. #17  
    Apocalyptism
    Harry's Avatar
    Join Date
    Apr 2007
    Posts
    3,783
    Thanks given
    594
    Thanks received
    1,833
    Rep Power
    2934
    Quote Originally Posted by S a n t a Pk View Post
    thanks dont think ill use but i might
    lmfao
    ~ Harry
    Please bear this in mind when hearing the word 'soon' from a software programmer.

    As coding software generally takes thousands of years, software programmers have developed a natural adaptation to this in the form of an altered perception of the flow of time.

    Due to this, the word 'soon' when uttered by a programmer should be taken to mean 'a very, very long time from now' in the terminology used by common human specimens who have not developed such an adaptation.
    knowledge can be taught, but passion cannot.
    It's better to create something that others criticise than to create nothing and criticise others.
    Reply With Quote  
     

  8. #18  
    Respected Member


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    12,549
    Thanks given
    177
    Thanks received
    5,784
    Discord
    View profile
    Rep Power
    5000
    Good job lol, don't think i have any use for it though.

    Reply With Quote  
     

  9. #19  
    Registered Member
    Warlock 999's Avatar
    Join Date
    Jul 2008
    Age
    28
    Posts
    1,407
    Thanks given
    7
    Thanks received
    29
    Discord
    View profile
    Rep Power
    927
    Hey blood, How come it wont show up? its like invisible.

    This is my constructor

    Code:
        public Sprite(String customSpriteLocation) {
            try
            {
            Image image = Toolkit.getDefaultToolkit().getImage(""+customSpriteLocation+".png");
            System.out.println(customSpriteLocation);
                anInt1444 = myWidth;
                anInt1445 = myHeight;
                anInt1442 = 0;
                anInt1443 = 0;
                myPixels = new int[myWidth * myHeight];
                PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
                pixelgrabber.grabPixels();
            image = null;
            }
            catch(Exception _ex)
            {
                System.out.println(_ex);
            }
        }
    The constructor works everytime i see the item it prints out
    ./.delta_cache_V2/whip.PNG

    Also this is the code in item def

    Code:
            if(i == 4151)//new rs whip
            {
                itemDef.name = "New rs whip";
                itemDef.customSpriteLocation = signlink.findcachedir() + "whip.PNG";
            }
    Do you know whats wrong?
    If anyone needs help with java questions or errors I will try and help with what I can/know
    my discord is Perkaholic feel free to add me with questions or to chat!

    "There is always one more thing you can do to increase your odds of success." -Hal Moore
    Reply With Quote  
     

  10. #20  
    Apocalyptism
    Harry's Avatar
    Join Date
    Apr 2007
    Posts
    3,783
    Thanks given
    594
    Thanks received
    1,833
    Rep Power
    2934
    Quote Originally Posted by Warlock 999 View Post
    Hey blood, How come it wont show up? its like invisible.

    This is my constructor

    Code:
        public Sprite(String customSpriteLocation) {
            try
            {
            Image image = Toolkit.getDefaultToolkit().getImage(""+customSpriteLocation+".png");
            System.out.println(customSpriteLocation);
                anInt1444 = myWidth;
                anInt1445 = myHeight;
                anInt1442 = 0;
                anInt1443 = 0;
                myPixels = new int[myWidth * myHeight];
                PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
                pixelgrabber.grabPixels();
            image = null;
            }
            catch(Exception _ex)
            {
                System.out.println(_ex);
            }
        }
    The constructor works everytime i see the item it prints out
    ./.delta_cache_V2/whip.PNG

    Also this is the code in item def

    Code:
            if(i == 4151)//new rs whip
            {
                itemDef.name = "New rs whip";
                itemDef.customSpriteLocation = signlink.findcachedir() + "whip.PNG";
            }
    Do you know whats wrong?
    you dont need to do anything like:

    Code:
        public Sprite(String customSpriteLocation) {
            try
            {
            Image image = Toolkit.getDefaultToolkit().getImage(""+customSpriteLocation+".png");
            System.out.println(customSpriteLocation);
                anInt1444 = myWidth;
                anInt1445 = myHeight;
                anInt1442 = 0;
                anInt1443 = 0;
                myPixels = new int[myWidth * myHeight];
                PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
                pixelgrabber.grabPixels();
            image = null;
            }
            catch(Exception _ex)
            {
                System.out.println(_ex);
            }
        }
    just make sure you do this part of the tut

    Code:
    ItemDef itemDef = ItemDef.forID(j9);
                                        
                                        if (itemDef.customSpriteLocation != null)
                                        {
                                        	class30_sub2_sub1_sub1_2 = new Sprite(itemDef.customSpriteLocation);
                                        }
    ~ Harry
    Please bear this in mind when hearing the word 'soon' from a software programmer.

    As coding software generally takes thousands of years, software programmers have developed a natural adaptation to this in the form of an altered perception of the flow of time.

    Due to this, the word 'soon' when uttered by a programmer should be taken to mean 'a very, very long time from now' in the terminology used by common human specimens who have not developed such an adaptation.
    knowledge can be taught, but passion cannot.
    It's better to create something that others criticise than to create nothing and criticise others.
    Reply With Quote  
     

Page 2 of 3 FirstFirst 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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