Hello Guest it is March 28, 2024, 06:12:21 AM

Author Topic: Stretching Images  (Read 2212 times)

0 Members and 1 Guest are viewing this topic.

Stretching Images
« on: May 24, 2016, 12:39:31 PM »
Is there a way to set a static image so it won't stretch or resize with the screen?  A way to lock the aspect ratio would work also.  Anything to prevent the image from distorting.  I was kind of hoping for a "resized" event attached to the tab panel object, but don't see anything like that.

Thanks
Re: Stretching Images
« Reply #1 on: May 26, 2016, 11:52:41 PM »
I'm guessing there is not a way to lock images.  This is driving me nuts.  I'm trying to make a nice looking screen with images and image buttons, but it's impossible when the images distort when the screen size changes.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Stretching Images
« Reply #2 on: May 27, 2016, 02:41:54 AM »
There is a way but just not had time to go indepth with a vidieo yet, its done by using a panel and a wxstaticbitmap command, hopefully I will sort weekend.

DazTheGas
New For 2022 - Instagram: dazthegas

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Stretching Images
« Reply #3 on: May 27, 2016, 02:44:07 AM »
Another quick way is to make your screen editor screen the same size as the normal screen, this stops the sizers from sizing when exiting the editor.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Stretching Images
« Reply #4 on: May 27, 2016, 10:33:58 AM »
Static screen size doesn't really work because you never know what size screen a user will have.  The fact that it resizes is actually a nice feature...One I always wished M3 had...It just doesn't work when applied to images and image buttons.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Stretching Images
« Reply #5 on: May 27, 2016, 03:34:48 PM »
Not time for a video but try this..

from the screen editor

1. Add a lua panel and set the size the same as the image you want + 10 on both height and width
2. Add into the script part

Code: [Select]
local inst = mc.mcGetInstance()
    panel = mcLuaPanelParent -- get the panels parent id
    local window = panel:GetParent() -- get the panels id
    local BGround = panel:GetBackgroundColour() -- get the screen background colour
    window:SetBackgroundColour(BGround) -- set to background of top window
    window:SetWindowStyleFlag(wx.wxBORDER_NONE) -- remove border
    window:ClearBackground() -- clear background
    window:Refresh() -- refresh to apply changes

local my_image = "C:\\DTG_Mach4Hobby\\Profiles\\ESS_Motion_V2\\Screen\\Buttons\\24v_dwn.png" -- bitmap to load

wx.wxStaticBitmap( window, wx.wxID_ANY, wx.wxBitmap( my_image , wx.wxBITMAP_TYPE_ANY ), wx.wxDefaultPosition, wx.wxDefaultSize, 0 ) -- create the bitmap container

window:Layout() -- redraw the new panel

This will create a bitmap that will not resize with the screen, the panel itself will but not the image.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Stretching Images
« Reply #6 on: May 27, 2016, 07:02:33 PM »
You're my hero!  That works great.