Home AMX User Forum AMX Design Tools

Changing Image assigned to Slot

Hi there,

Could some one please let me konw if is there a way to change the image (Bitmap) assigned to Slot by netlinx code .

Something like this :

send_command dvTP," .. 'image.bmp' .. Slot=23.. " or an other


Thanks in advance

Comments

  • jjamesjjames Posts: 2,908
    There are no commands that accomplish this. Use the ^ICO command to change which icon the button uses.
  • the8thstthe8thst Posts: 470
    You could also use dynamic images and use ^RMF to change the filename and/or path of the image.
  • jjamesjjames Posts: 2,908
    Dynamic images can only be used as a Bitmap. The button's Bitmap property would need to be changed to act as the Icon, and the Icon as the Bitmap, then you could have a "Dynamic Icon" of sorts.
  • the8thstthe8thst Posts: 470
    jjames wrote: »
    Dynamic images can only be used as a Bitmap. The button's Bitmap property would need to be changed to act as the Icon, and the Icon as the Bitmap, then you could have a "Dynamic Icon" of sorts.

    Or you just include the entire button image in the bitmap file and you don't have to worry about layering two separate images.
  • jjamesjjames Posts: 2,908
    Right - but totally misses the point of using icons. A million ways to skin a cat, and agree I'd go with what you're saying, just trying to stay within the box of which the OP brought up. :)
  • joseaniojoseanio Posts: 42
    Icon <> Bitmap

    Thanks guys by your point of view.

    I know that I can change the buttons' bitmap or Icon . But in this case i should change all over the Pages' Images from my project.
    I am looking for a way to change all of them with only one command.

    The idea about the dynamic image is good , but i would like to put all solution on the box.

    I will still study and opened to suggestions.
  • DHawthorneDHawthorne Posts: 4,584
    The whole icon slot thing is kind of obsolete, and, as near as I can figure, was just a way to put multiple images on the same button in G3 panels that didn't have the pass-through property. There is no reason, and no benefit to using it as the sole image on a single button. Although the "bitmap" property is named the way it is, you can also use png files, you aren't limited to bmp. And if you absolutely must have two images, I think you are better off overlaying a transparent button with pass-through than mucking around with icon slots.

    The biggest problem with icon slots is that they don't transfer well between projects. I can't tell you the times I've copied pages from a download module that used icon slots, and then had to manually go through each and every button to correct the images. If you copy a page into your project that is using icon slots that are already in use, it just assigned them to available slots. But the property refers to the original slots, and the wrong image is displayed. And since everyone who writes a module for distribution uses the lowest slot numbers, it happens pretty much every time.

    So my advice is, don't use them.
  • jjamesjjames Posts: 2,908
    *GASP!*

    I have to strongly disagree with your assessment as icons being obsolete. While I use them more often than not at some point, it's for exactly what you said: overlaying two images.

    In some of my designs, I have a bitmap that can be used for multiple buttons - think a gradient that spans 800 pixels and has a height of 100. (And others that are 40, 50, 60, 80, 120, etc. in height.) I know several people that do this and have seen it in some of AMX's designs, so it's not a new concept. So that takes up the "Bitmap" property, so if I want an icon or image of say a Wii or an XBox on it I shouldn't have to actually layer two buttons - that is when I use an "Icon." I can resize the button as much as I want and keep the icon where it's supposed to be in relation to the button. I don't have to move a second button and align it where I want . . . now do this for say 8 buttons, and then you have to add a 9th, or remove one and re-align them all. There's an option to space buttons evenly - with your two button scenario - it just doesn't work.

    And I haven't even touched on changing the Icon property from code. Do you have two button addresses? One for the passthrough "icon" button and one for the other if you need to change any property? When using icon slots - you can change it all with a single BMF command.

    Everything you've described is too much work for me, so I'll stick with the obsolete icon and not have to worry about moving two buttons. :)
  • DHawthorneDHawthorne Posts: 4,584
    I think it's even more work to have to go through every page on a design, figure out what graphic was supposed to be on a button, then change the icon slot to match.

    We all do things the way we feel most comfortable with. I use modules extensively, and I create panels with the express intent to copy and paste pages from one project to another. This is where icon slots fail. Every third party that creates panel pages uses the same set of slots. If you have several dozen modules of there own, it's impossible to create a slot scheme where they will never overlap. Therefore, it's impossible in either situation for the icons to be correct when copied into another design.

    If you hand-craft every page from scratch for every project, it won't be an issue. But that's not how I work, so they don't work for me.
  • jjamesjjames Posts: 2,908
    I hear ya - I've seen that problem plenty of times. I start my panels out with a custom design that's easily editable and has most sources we'd ever use between jobs. There's very little copying & pasting - I just start fresh with from a template that's pretty much universal for us and go from there, so it's not much of a problem.

    The managing of icons can be a pain - I totally agree - but my opinion of dealing with two buttons to get the image-on-image look still stands.

    . . . I wish there was a better saying than "There's a million ways to skin a cat" and hold the same sentiment. :)
  • a_riot42a_riot42 Posts: 1,624
    I use the slots as well but only on a limited number of buttons to avoid the displaced slots when cutting and pasting, so I wouldn't say they are obsolete. Sometimes slots are better, other times multiple buttons are better, sometimes both are needed, I think it depends on what you are doing.
    Paul
  • viningvining Posts: 4,368
    I've manage to get by with out ever using slots, I don't recall ever even trying to use them.
  • the8thstthe8thst Posts: 470
    I only use slots for channel presets and source select buttons.

    I wonder if you can use an integer array in the ^ico command like you can with ^sho. That might clear up the original poster's question.
    define_variable
    integer nButtonChannels[] = {1,3,5,6,10,207,99}
    
    define_event
    button_event[dvTP,1]{
        push: {
            send_command dvTP,"'^ICO-',nButtonChannels,'1&2,<index>'"
        }
    }
    

    You still need to have all of your images preloaded, but it would let you change a big number of buttons with one command.
  • jjamesjjames Posts: 2,908
    According to AMX-PI, you should be able to.
  • joseaniojoseanio Posts: 42
    I use slots to allow the User to change the order of the channels defined in the pages of favorites

    Something like this:
    Joseanio wrote:

    button_event [dvTP_TVCR_MEMO,0]
    {
    push:
    {
    nTvcrBotao = button.input.channel
    SEND_COMMAND dvTP_TVCR_MEMO,"'?ICO-',ITOA(button.input.channel),',1&2'"
    }
    hold[30]:
    {
    // change slot of button
    nTvcrBotao = button.input.channel
    send_command dvTP_TVCR_MEMO,"'?ICO-',ITOA(button.input.channel),',1&2'"
    IF ( nTvcrCHANNEL = 0 )
    {
    send_command dvTP_TVCR_MEMO,"'@TKP-;Novo Canal'"
    }
    ELSE
    {
    send_command dvTP_TVCR_MEMO,"'@TKP-',ITOA(nTvcrCHANNEL),';Novo Canal'"
    }
    nMudaCanal = 1
    }
    }

    custom_event [ dvTP_TVCR_MEMO,nTvcrBotao,1003]
    {
    IF ( custom.value2 > 0 )
    {
    IF ( nTvcrCHANNEL <> custom.value2 - 300 )
    {
    nTvcrCHANNEL = custom.value2 - 300 // icon index
    send_command dvTVCR_IR,"'XCH ',ITOA(nTvcrCHANNEL)"
    send_command dvTP_TVCR,"'^TXT-10,0,',ITOA(nTvcrCHANNEL)"
    on[dvTP_TVCR_MEMO,nTvcrBotao]
    }
    }
    ELSE IF ( custom.value2 = 0 )
    {
    nTvcrCHANNEL = 0
    }
    }
    data_event [dvTP]
    {
    string:
    {
    IF ( find_string(data.text,'KEYP-',1) and nMudaCanal = 1 )
    {
    REMOVE_STRING(data.text,'KEYP-',1)
    nTvcrCHANNEL = ATOI(data.text)
    nMEMOChannel[nTvcrBotao] = nTvcrCHANNEL+300
    SEND_COMMAND dvTP_TVCR_MEMO,"'^ICO-',ITOA(nTvcrBotao),',1&2,',ITOA(nTvcrCHANNEL+300)"
    nMudaCanal = 0
    }
    }
    }

    the8thst wrote: »
    I only use slots for channel presets and source select buttons.

    I wonder if you can use an integer array in the ^ico command like you can with ^sho. That might clear up the original poster's question.
    define_variable
    integer nButtonChannels[] = {1,3,5,6,10,207,99}
    
    define_event
    button_event[dvTP,1]{
        push: {
            send_command dvTP,"'^ICO-',nButtonChannels,'1&2,<index>'"
        }
    }
    

    You still need to have all of your images preloaded, but it would let you change a big number of buttons with one command.
Sign In or Register to comment.