Is it possible to use Base64 DotNet Image Encoder http://lonerobot.net/?p=314
in connection with http://www.scriptspot.com/3ds-max/tutorials/maxscript-image-button-bmp-l…
so that I could encode both - image and alpha and call functions for both images?
logo.images = #((StringToImage img_logo), (StringToImage img_logo_alpha), 1,1,1,1,1 )
for example inside this code (by barigazy)
rollout testRoll "LOGO"
(
--if you want to convert image to string see these link: http://www.scriptspot.com/3ds-max/scripts/base64-dotnet-image-encoder
local img_logo = "..."--encoded image
local img_logo_alpha = "..."--encoded image alpha
local ConvertClass = dotNetClass "System.Convert"
local ImageClass = dotNetClass "System.Drawing.Image"
fn StringToImage str = -- http://lonerobot.net/
(
byteArr = ConvertClass.FromBase64String str
memstream = dotnetobject "System.IO.MemoryStream" byteArr
DecodedImg = ImageClass.fromstream memstream
memstream.close() ; return DecodedImg
)
dotnetcontrol logo "Label" pos:[0,0] width:100 height:100
on testRoll open do (logo.image = (StringToImage img_logo))
)
createDialog testRoll 100 100 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
)
Comments (19)
Comment policy
hmmm
Thx barigazy! You really helped me a lot!
Look! I've found the solution with alpha
inside on open... I need to use
but what should I put instead of "slategray", in order to detect the color scheme?
:)
Don't tell me that you forget to add backcolor:)
If you need max default BG and FG color than you can use this
But I prefere this method for custom color
fn defColor r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b)
dnBC = (defColor 60 60 60)
dnFC = (defColor 200 200 200)
--e.i
logobtn.backcolor = dnBC --for beckground
logobtn.forecolor = dnFC --for text
Also put all your .net objects (controls) definition inside function. You can save time a lot.
Example for labeldefinition
You welcome ;)
STRANGE
I get white inside image where I have transparency! I've saved it correctly in png format! I'm sure about that!
may be I need background!
Very interesting about saving to hdd! But I don't understand why, anyway, it's giving the image! Is it about speed?
Create a Bitmap containting text from a String
Code by Rafaelo Insanto Steves
(
local str = "SomeFileName.ms" --thats the string wich will be put out
local bmapPath = @"C:\Users\Insanto\Desktop\alphabet.tga" --this path needs to lead to the bitmapFile containing the letters, numbers and signs
local bMap = openBitmap bmapPath
local letterArr = #("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"," ","-","_",".","+","&","#","!",":","?")
--build the single letters
local letterBMs = #()
for l = 1 to str.count do
(
local letter = str[l]
local letterBM = bitmap 11 12
local startpoint = if letter != "A" then 12 * ((findItem letterArr letter)-1) else 0
for y = 0 to 11 do
(
local ps = getPixels bMap [startpoint,y] 11
setPixels letterBM [0,y] ps
)
letterBMs[l] = letterBM
)
--build the full string from the letters
local fullWidth = letterBMs.count * 11
local strBM = bitmap fullWidth (12+2*2) color:white
for b = 0 to letterBMs.count-1 do
(
local startpoint = 11*b
for y = 0 to 11 do
(
local ps = getPixels letterBMs[b+1] [0,y] 11
setPixels strBM [startpoint,y+2] ps
)
)
display strBM
letterBMs = undefined --make sure to leave this line so the gc can remove the letter bitmaps from memory
close bMap
)
same author
fn string2Bmp str =
(
if classOf str == string do
(
local pixlRows = filterString str "BR" splitEmptyTokens:false ; pixlRows = for i in pixlRows collect execute i
local resBMP = bitmap pixlRows[1].count pixlRows.count
for y = 0 to pixlRows.count-1 do
(
setPixels resBMP [0,y] pixlRows[y+1]
)
return resBMP
)
)--END string2Bmp FN
THANK YOU SO MUCH!
I will try now!!!
One more tip
Look at this Pete tool http://www.scriptspot.com/3ds-max/scripts/speechbot
When you first time run this tool all buttons icons are created and saved on HDD.
This aproch is better (using icons from script folder) then creating them over and over again.
Cool right?
edit
One more colored test script. Funny stuff you can learn here
http://www.scriptspot.com/3ds-max/scripts/ineractive-labels
Cheers!
I know about them inside MICROSOFT WORD
but they don't have all signs that I need. Some of them I draw in PHOTOSHOP
except this I can't make it work like a simple button
if I use
then it does not animate like a button
if I use
then I get this ugly border, but it's animating
Use label and for hilighting you can use "MouseHover" and "MouseLeave" events wher you can change contrlol "backcolor"
I avoid using the bitmaps in my scripts. Are you hear about symbolic systems
fonts like "Wingdings" and "Webdings"?
It'smuch fester and beter to use theses as fontstyle then bitmaps
yes I know
It works wonderfull. but how to make it work for both - image and alpha! This is the first situation! The second is that when I want to use it for buttons
I get an ugly border! - http://www.scriptspot.com/files/ugly_button.jpg
but I need smth like this http://www.scriptspot.com/files/needed.jpg
Attachments
Try with *.png
to convert png
or to use external file?
I would prefer to use img as string inside ms
Yep to convert *.png image to string using Pete's tool.
He put his logo at the top of script (little robot) as *.png If you have not noticed.
:)
this is mine earlier test using same Pete "LoneRobot" method
Attachments