Gifs on Sailfish-os - linux

I came here with a little problem, i can't use any local .gif in my code.
I work on Linux with QtCreator and the Sailfish VM to make a Sailfish-os application.
I tried first this example, without any success.
Rectangle {
width: animation.width
height: animation.height
AnimatedImage { id: animation; source: "../images/animatedimageitem.gif"}
}
The execution return :
QML AnimatedImage: Error Reading Animated Image File file:///bla/bla/.....
Same problem with other permissions on the gif and with an other gif.
After some researches I found this page where someone indicate to download a plugin, but Qt declare (I wish i could put a link but i'm new -_-', see comments) that gifs are already support by default.
The plugin was finally unobtainable and I found this Sailfish/bin/plugins/imageformats/libqgif.so in my directories.
So what can i do to show a gif on this damn thing ?

The error you are seeing is probably related to filepaths. Gifs are supported, AFAIK.
Instead of coding the path that way, consider the usage of a resource file to improve portability and platform independence.
Create a new resource file (File -> New File or project -> Qt -> Qt Resource File)
The property editor opens, click Add in the bottom then Add prefix and set a prefix such as / (or whatever you like!)
Click again to select Add files and insert your image
Right-click the newly added image entry and copy resource path to Clipboard
Build -> Run qmake (fundamental to ensure correct compilation)
The path you copied in the clipboard should be of the form:
://PATH_TO_IMAGE.gif
Now, given your QML code, I can guess the image folder is inside source code at the same level as the QML folder. Hence, if you added the .gif file from that folder you would have the following path in the clipboard:
://images/name.gif
This can be prepended with the prefix to obtain the final path. If your prefix is set to /, as we did above, the final string to be set in the source property of your AnimatedImage would be:
"qrc:///images/name.gif"
Obviously, a different prefix or a different path would result in a different final path.

Well..... I just put it on my phone (Jolla) and the gif works well. So this is the VM who doesn't seems to like gifs ...
Thanks for help though,
Psycho.

Related

How can I use Base64 image paths in AppleScript?

I have come up with an AppleScript, to monitor my VPN connection from VPN Tracker. So far I got the code working, meaning it shows the correct state as text. I created two PNG files, which I converted into Base64 and would like to use those as the status output, instead of just having text. The reason for the Base64 conversion of the images is, so I can share the script with others, without needing to share the actual images as well and expect the user to put them somewhere on his Mac.
I am however unsure of how to decode those Base64 strings in AppleScript, so it shows the actual image in the end.
This is the code I have so far (with the text output)
set conn_state to "" as string
if application "VPN Tracker 365" is running then
tell application "VPN Tracker 365"
try
if name of groups contains "group_name" then
set conn_state to state of connection of group ("group_name") as string
if conn_state = "On" then
return "VPN active"
else
return "VPN inactive"
end if
end if
on error
return "An error occured"
end try
end tell
end if
I did do some research on the internet but could not find anything that would help me, solve this problem, or I was maybe not using the right search terms.
Any help would be much appreciated. Thanks in advance
"The reason for the Base64 conversion of the images is, so I can share the script with others, without needing to share the actual images as well and expect the user to put them somewhere on his Mac."
Consider taking a different approach. The following solution will enable the image(s) to be bundled within your Applescript and avoid having to Base64 encode/decode them:
Save your AppleScript as an "Application" format via the AppleScript Editor.
Locate your resultant application via the "Finder"
Click on it while pressing the ctrl key.
Via the context menu choose "Show Package Contents".
Copy your .png image(s) to the Contents/Resources folder.
Then in your code access the path to the image as follows:
# Get the pathname to where this script resides in the filesyetem.
set pathToMe to (path to me) as text
# Create the full pathname to the image
set pathToPng to pathToMe & "Contents:Resources:img.png" as alias
# Just a demo to illustrate that the image path can be accessed.
tell application "Preview" to open pathToPng
Note: This example code assumes you've copied an image named img.png to the Contents/Resources folder. It firstly obtains the path to wherever your app is located and assigns the images path to the pathToPng variable
Edit:
Or, as #user3439894 kindly mentioned in the comments, simply use the following code to obtain the path to the image(s) directly:
# Create the full pathname to the image
set pathToPng to path to resource "img.png"
# Just a demo to illustrate that the image path can be accessed.
tell application "Preview" to open pathToPng
Note: This utilizes path to resource to obtain the path of the image, and the aforementioned steps 1-3 are still necessary

python pywinauto file selection dialog

I am in the process of automating a firmware update for a specific component we use a work a lot. I have the automation of the gui completed (and working) except for this particular screen.
What I need to do, is have the program automatically navigate to the correct folder (standardized across machines) and select the correct file to use for the update.
Here is my code so far:
from pywinauto.application import Application
app = Application(backend='win32').connect(title_re=".*EBDS*", found_index=0)
main_dlg = app.window(title_re=".*EBDS*", found_index=0)
main_dlg.child_window(title="Launch Control Panel", control_type="System.Windows.Forms.Button").click()
sub_dlg = app.window(title_re=".*Bill Acceptor*", found_index=0)
sub_dlg.child_window(title="Open", control_type="System.Windows.Forms.Button").click()
sub_dlg.child_window(title="Download", control_type="System.Windows.Forms.Button").click()
file_dlg = app.window(title_re=".*download*", found_index=0)
It has a couple sub windows that pop up after clicking, thus the main_dlg, sub_dlg, and file_dlg.
I have already told it to select the download button, and it pops up the "select a file to download" window.
What I need to do now is be able to specify the path (where it says This PC), change the file type (currently says Bin files), and select the correct file.
I have done a "print control identifiers" and here is the link to the txt file of that output (it's over 3k lines, so I didn't want to paste it here) Control Identifiers .txt
What I then did was I correctly (manually) went through the steps to get it where it needs to be, and did another "print control identifiers." Again, this is over 3k lines long, so here is a Link to that output.
Assuming that I'm doing this right, the file path location in the gui is:
file_dlg.child_window(title="Select a file to download.", class_name='#32770').child_window(class_name="WorkerW").child_window(class_name="ReBarWindow32").child_window(class_name="Address Band Root").child_window(class_name="msctls_progress32").child_window(class_name="Breadcrumb Parent").child_window(title=".*Address:*", class_name="ToolbarWindow32")
The question is, how do I interact with that object specifically? A .click() or .sendkeys() both error out.
Bonus points if you can figure out how to change the file type.
I'm open to an easier/different way of doing this, however this has to be deployable to a couple hundred machines that don't have the same screen size, ergo I cannot use pyautogui and pixel counts.
Any ideas?
You can enter the full file path to the edit box and click "Open" button. It should look like this:
file_dlg = app.window(title_re=".*Select a file to download*", found_index=0)
file_dlg.FileNameEdit.set_edit_text("full_path_to_file")
file_dlg.child_window(title="&Open", control_type="Button").click()
I assume you have to bypass .click_input() and .type_keys(...) usage as they require active desktop which is hard to maintain on a big pool of machines.

Deploy and load a picture to use as a texture in a holographic app

I created a sample holographic application in Visual Studio 2015 with C++/CX (or whatever they call that fancy C++ with hats and ref new). It builds, deploys and runs fine, rendering a rotating colored cube, just as it's supposed to. Now I am trying to add a jpeg image and use it as a texture on the cube. The question is, where shall I put the image, how do I add it to the project, how do I make VS to deploy it along with the rest of the project, and how do I load it in my application?
I have literally zero experience with both DirectX and UWP. I've done this tutorial on textures on my desktop Windows 10 (a regular C++ app, not managed, not UWP), although the way they load a file into a texture in the tutorial didn't work for me. After some googling I downloaded this library, built it for desktop Windows 10 (DirectXTex_Desktop_2015_Win10.sln) and used in my project as follows:
DirectX::ScratchImage image;
LoadFromWICFile(L"myimage.jpg", DirectX::WIC_FLAGS_NONE, nullptr, image);
CreateShaderResourceView(d3d11Device, image.GetImages(), image.GetImageCount(), image.GetMetadata(), &CubesTexture);
It worked. Now, for Hololens I built their DirectXTex_Windows10.sln solution (assuming that if the other one was for desktop, this one must be for non-desktop) and tried (unsuccessfully) using it like this:
DirectX::ScratchImage image;
HRESULT hr = LoadFromWICFile(L"ms-appx:///myimage.jpg", DirectX::WIC_FLAGS_NONE, nullptr, image);
CreateShaderResourceView(m_deviceResources->GetD3DDevice(), image.GetImages(), image.GetImageCount(), image.GetMetadata(), &m_cubesTexture);
I also tried ms-appdata instead of ms-appx. In both cases LoadFromWICFile does not return S_OK. It gives ERROR_INVALID_NAME: The filename, directory name or volume label syntax is incorrect. As for myimage.jpg, I put it into the Assets subfolder and added to the solution through Add->Existing Item. Is that enough to get it deployed to Hololens? How do I check if it gets deployed? Where on the device is it going to be located, if deployed?
It seems I over-complicated things.
To add a file like that into a project, simply use right click (on the Assets sub-folder in the solution explorer) -> Add -> Existing Item. To get it deployed on the device or emulator, right click on the file -> Properties, set Content to Yes and Item Type to Image or Does not participate in build (for something that doesn't get recognized correctly, for example, Wavefront .OBJ file, which VS would otherwise try and fail to link).
To check if (and where) the file is going to be on the device or emulator, you can build an actual package: right click on the project, choose Store->Create App Packages... It creates an .appx file, which is actually a zip-archive. You can explore it with an archiver like 7zip, or rename it from .appx to .zip and open with Windows File Explorer. In my case the image file was there, in the Assets subfolder. I was able to read it by its simple relative path, like this (no ms-appx:/// or other such prefixes):
HRESULT hr = LoadFromWICFile(L"Assets/myimage.jpg", DirectX::WIC_FLAGS_NONE, nullptr, image);
For some other functions (std::fopen, std::ifstream etc.) this relative path didn't work, I had to use the full path as follows:
Platform::String^ appInstallFolder = Windows::ApplicationModel::Package::Current->InstalledLocation->Path;
std::wstring folderNameW(appInstallFolder->Begin());
std::string folderNameA(folderNameW.begin(), folderNameW.end());
std::string fname = folderNameA + std::string("/Assets/model.obj");
std::FILE *f = std::fopen(fname.c_str(), "r");
This textured cube project might give you some insight. I think is based on the C# VS2015 Holographic template.
https://github.com/dngoins/HololensDXTutorials

minko / lua issue : premake5.lua:3: attempt to index global 'minko' (a nil value)

I am working with minko and managed to compile MINKO SDK properly for 3 platforms (Linux, Android, HTML5) and build all tutorials / examples. Moving on to create my own project, I followed the instructions on how to use the existing skeleton project, then using an existing example project.
(I believe there is an error in the skeleton code at this line :
auto sceneManager = SceneManager::create(canvas->context()); //does not compile
where as the example file look like this :
auto sceneManager = SceneManager::create(canvas); //compile and generate binary
I was able to do so by modifying premake5.lua (to include more plugins) and calling script/solution_gmake_gcc.sh
to generate the make solution a week ago. Today, I tried to make a new project in a new folder but calling
script/solution_gmake_gcc.sh and script/clean failed with this error:
minko-master/skel_tut/mycode/premake5.lua:3: attempt to index global 'minko' (a nil value)
Now at premake5.lua line 3 there is this line : minko.project.solution(PROJECT_NAME),
however sine i am not familiar with lua at all, can anyone shed any light on the issue ?
What is supposed to be declared here, why is it failing suddenly... ?
(I can still modify,compile and run the code but i can't for example add more plug-ins)
PS: weirdly enough, the previously 'working' project is also failing at this point.
Thanks.
PROJECT_NAME = path.getname(os.getcwd())
minko.project.application("minko-tutorial-" .. PROJECT_NAME)
files { "src/**.cpp", "src/**.hpp", "asset/**" }
includedirs { "src" }
-- plugins
minko.plugin.enable("sdl")
minko.plugin.enable("assimp")
minko.plugin.enable("jpeg")
minko.plugin.enable("bullet")
minko.plugin.enable("png")
--html overlay
minko.plugin.enable("html-overlay")
Assuming that's indeed your project premake5.lua file (please us the code tags next time), you should have include "script" at the beginning of the file:
https://github.com/aerys/minko/blob/master/skeleton/premake5.lua#L1
If you don't have this line, it will not include script/premake5.lua which is in charge of including the SDK build system files that defines everything inside the minko Lua namespace/table. That's why you get that error.
I think you copy pasted one of the examples/tutorials premake5.lua file instead of modifying the one provided by the skeleton. The premake conf file of the examples/tutorials are different since they are included from the SDK premake files. But your app premake5.lua does the "opposite": it includes the SDK conf files rather than being included by them.
The best practice is to edit your app's copy of the skeleton's premake5.lua (instead of copy/pasting one from the examples/tutorials).
(I believe there is an error in the skeleton code at this line :
That's possible. Our build server doesn't test the skeleton code. That's a mistake we will fix ASAP to make sure it works properly.
script/solution_gmake_gcc.sh and script/clean failed with this error:
minko-master/skel_tut/mycode/premake5.lua:3: attempt to index global 'minko' (a nil value)
Could you copy/paste your premake5.lua file?
Also, what's the value you set for the MINKO_HOME env var? Maybe you've moved the SDK...
Note that instead of setting a global MINKO_HOME env var, you can also set the corresponding LUA constant at the very begining of your premake5.lua file.

Getting the full path of a DirectoryEntry

Does anyone know how to get the full path of a DirectoryEntry object in a Chrome Packaged App, without any tildes or other shortcuts?
I am writing a Google Chrome Packaged App. My app has a button where a user can choose a directory using chrome.fileSystem API. When the directory choice comes back to my app, it is represented by a DirectoryEntry object, which is defined in the File API. The object looks like this in the console:
DirectoryEntry {
filesystem: DOMFileSystem
fullPath: "/to_read"
isDirectory: true
isFile: false
name: "to_read"
__proto__: DirectoryEntry
}
I am using Windows and the full path of the directory is
C:\Users\David\Desktop\to_read
I would like a function that can return that path or something close. Unfortunately, the closest thing I found is chrome.fileSystem.getDisplayPath, but that returns the following:
~\Desktop\to_read
The return value from getDisplayPath is not useful to me, because I want to get the full name of the directory (including the drive) so I can compare it to some other full directory paths I have.
I tried calling toURL() on the DirectoryEntry and it returned an empty string.
A bit about my project: I want to write an iTunes library synchronizer as a Chrome Packaged App. The iTunes library XML file contains full paths like file://localhost/D:/David/Music/Bob/Bob%20Album/01%20Bob.mp3. The user will give my app access to his music folders, and I want to be able to tell if he gave me access to the right folders.
The only full paths available are those returned by getDisplayPath.
The mediaGalleries API may be a better fit for your project: http://developer.chrome.com/apps/mediaGalleries.html#iTunes.
If you have a full path path/to/the/file.mp3 and you want to load the file directly with tis you can do it but the solution is not perfect. Use the chrome.mediaGalleries API to ask where the user saves his music (in your case), then you can write a loop who check if one of the path repository is equal to a gallery.
For example if you got a file path/to/the/file.mp3 from the xml file and your galleries list looks like ["D", "to", "Videos"], write a function to check if each component of the file's path is a gallery. In this case your code will find "to", so you can launch a second function who use "the/file.mp3".
The second function has to use the given path and find if the gallery contains the right folders and finally the right file (use this example by Google). In the case you're trying to find "the/file.mp3" with the gallery to your loop has to find a directory named "the" then "file.mp3" (write a recursive function), if you find the file open it, otherwise come back to the first function if you haven't check all the galleries or all the path's component.
This is currently (2014-01-10) not a feature of Chrome, but I have suggested it and they are working on it:
https://code.google.com/p/chromium/issues/detail?id=322952

Resources