[NTLK] Importing .pngs
Matthias Melcher
m.melcher at robowerk.de
Thu Oct 22 10:47:15 PDT 2026
> On 22. Oct 2026, at 19:22, Doug <ispinn at gmail.com> wrote:
>
> "The compiler can import .png images now, so you appd can have nice
> graphics."
>
> ELI5, explain it like I'm 5: how'd you manage to add and mix this ability
> into the compiler and why do you think it hadn't been there earlier?
>
> I'm being blown away once a day or seems with the pace and the depth of the
> advancements that are happening lately.
>
> Thank you, thank you, thank you.
>
> Doug
Hi Doug.
To use this, you can download `newtc` which is a standalone compiler and decompiler, or you download VSNewt, which is a plugin for Visual Studio Code, that includes newtc and allow you to run apps on a Newton or on Einstein and debug them by setting breakpoints, single-step through the code, and look at variables and the call stack.
https://github.com/MatthiasWM/newton-framework/releases/tag/v0.4.0
https://github.com/MatthiasWM/VSNewt/releases/tag/v0.4.0
VSNewt comes with a sample program that shows how this works.
If you wanted set the icon for the package, for example, previoulsy you had to encode the pixel values into a binary block like so:
icon: {bits: Ref_45, bounds: Ref_46, mask: Ref_47},
iconPro: {
unhilited: {
bounds: Ref_46,
bits: Ref_45,
mask: Ref_47,
colorData: [
{
cBits: MakeBinaryFromHex("00000000001000000000000000200020000000000000000000000000000000"
"00000000000000FFFFFFFF000000000000000000000FFFFFFFFFFFFFF0000000"
"0000000000FFFF33333333FFFF00000000000000FFFF333333333333FFFF0000"
"0000000FFF3333333333333333FFF000000000FFF333333333333333333FFF00"
"000000FF33333333333333333333FF0000000FF3333333333333333333333FF0"
"0000FFF3333333333333333333333FFF0000FF333333FF33333333FF333333FF"
"0000FF33333FFFF333333FFFF33333FF000FF333333FFFF333333FFFF333333F"
"F00FF3333333FF33333333FF3333333FF00FF33333333333333333333333333F"
"F00FF33333333333333333333333333FF00FF33333333333333333333333333F"
"F00FF33333333333333333333333333FF00FF3333FFF333333333333FFF3333F"
"F00FF33333FF333333333333FF33333FF000FF33333FFF33333333FFF33333FF"
"0000FF333333FFF333333FFF333333FF0000FFF333333FFFFFFFFFF333333FFF"
"00000FF33333333FFFFFF33333333FF0000000FF33333333333333333333FF00"
"000000FFF333333333333333333FFF000000000FFF3333333333333333FFF000"
"00000000FFFF333333333333FFFF00000000000000FFFF33333333FFFF000000"
"00000000000FFFFFFFFFFFFFF000000000000000000000FFFFFFFF0000000000"
"0000000000000000000000000000000000", 'cBits),
bitDepth: 4
},
The new version of newtc has a command that does all that for you:
MakeIconFromPNG({file: "icon.png", depth: 4});
You can do that with regular images too, not only icons. There will eventually be the same thing for sound.
So an entire minimal app can look like this:
// test: a Newton app. F7 builds test.pkg, F5 runs it.
//
// newtc builds the package from what this file sets (newtc -build): the
// app's name, its icon, and theForm, its base view. Everything else has a
// sane default. NTK's names work: protoFloatNGo, vjParentCenterH, ...;
// kAppSymbol and kAppName (the label) are there once the name is set.
//
// newtc runs each statement on its own: a local doesn't reach the next one,
// a global (as greeting below) or a constant does. A bigger app can be
// split: Load("views.ns") runs that file (next to this one) here.
newtAppName := "test:SIG"; // the package's name; ":SIG" is your developer signature
newtAppLabel := "test"; // its name in Extras
newtAppIcon := MakeIconFromPNG({file: "icon.png", depth: 4}); // 16 grays, and black and white
newtAppCopyright := "Copyright 2026";
newt.theForm := {
_proto: protoFloatNGo, // a floater with a close box
viewBounds: {left: 0, top: 50, right: 200, bottom: 130},
viewQuitScript: func() Print("Goodbye")
};
greeting := {
_proto: protoStaticText,
text: "Tap the button",
viewBounds: {left: 10, top: 10, right: 190, bottom: 30}
};
AddStepForm(newt.theForm, greeting);
StepDeclare(newt.theForm, greeting, 'greeting); // the button's script finds it as greeting
helloButton := {
_proto: protoTextButton,
text: "Say Hello",
viewBounds: {left: 50, top: 40, right: 150, bottom: 60},
buttonClickScript: func()
begin
SetValue(greeting, 'text, "Hello from " & kAppName & "!");
Print(greeting.text); // in VS Code's Debug Console
end
};
AddStepForm(newt.theForm, helloButton);
More information about the NewtonTalk
mailing list