How to change the imageSource of image in? - livecode

I have an image in LiveCode that I would like to change to another image when a specific button is pressed. So far, I have tried this -
set the imageSource of image "The_Hangman" to "/HangMan/1.png"
However, I am getting an error code of:
execution error at line n/a (Object: can't set this property)
How do I fix this?

ImageSource refers to the image that is embedded in a text field, which is not what you want.
If you're using imported images, it's not intuitive at all, but the property you want to change is the text property:
set the text of image "abc" to the text of image "xyz"
Setting the text property changes the imageData and alphaData of the designated image at the same time.
If you're using referenced images (images outside your stack), set the fileName property of the image you want to change to the file path of the new image.

Here's how to do it using external image files:
Let's say you have your images stored in a folder called "images" that is in the same location on your disk as your stack file.
put "hang1.png,hang2.png,hang3.png" into tImgList
put 1 into tCurrImg
set the fileName of image "The_Hangman" to \
(specialFolderPath("resources") & item tCurrImg of tImgList)
Now by simply changing the value of tCurrImg you can display whichever external image file you want.

Related

Load image from JS to Phaser Game

I'm doing a custom game which I'd like to change the background and a character picture according to a file they upload.
The input file is outside phaser. If possible, I'd like to show the picture directly without uploading to the server.
If you use a file loader to get the base64 encoding of the image, you can use this.textures.addBase64 to load the image into the texture manager, after that loads you can create new objects with that image tag, or set existing images to that texture.
Working Example =>
https://stackblitz.com/edit/phaser-use-uploaded-image

Lotus Notes : How to limit the extension file type in the dialog box of the rich text lite field using thumbnails only?

Here is my problem: i have a rich text lite field, used to store a contact photo. Parameter of this field is:
- only allow for thumbnail with an image attachment name (mandatory) = ContactPhoto
Parameter of the Rich Text Lite
When the user clicks on it, a standard import dialog box (managed automatically by Notes) is open and all images type can be selected as shown here :
ScreenShot of the import dialog box
With the following code, I'm able to check the size of the photo:
Set uidoc=ws.CurrentDocument
Call uidoc.Refresh(True,True)
Set doc=uidoc.Document
oneKB = 1024
PhotoTrouve = False
Forall i In doc.Items
If i.type = Attachment Then
Set emb = doc.GetAttachment(i.values(0))
If emb.source="ContactPhoto" Then
PhotoTrouve = True
If emb.filesize > (50 * oneKB) Then
strError="The size of the photo should be less than 50 Kb."
End If
End If
End If
End Forall
If PhotoTrouve= False Then
strError="Photo is mandatory."
End If
But this is not enough. I also need to check if this is well a .jpg file. The problem is that, as this is a thumbnail, its name is ContactPhoto, without any extension and i don't know how to get the original extension of the file selected by the user (seems not to be possible).
So my question is : is it possible to force the standard dialog box of the "thumbnail rich text lite" field in order that it proposes only .jpg extension file type to the user ? How to ?
Or if not, do you know a solution to check that the original file is well a .jpg file ?
Note : even if I name the attachment CPhoto.jpg (instead of ContactPhoto) by example, the user can select all type of images, not only a jpg. The photo is saved in $FILE of the document under the name of CPhoto.jpg but I don't think that the file is finally a real .jpg format. And I absolutely need a jpg image as my final objective is then to export that image in an xml file, with the good format of jpg.
Thanks a lot for your replies and help.
Karen
You will have to translate it from C#, but code to check the file contents to see if it is a jpg can be found in this answer to a previous question on this site.

Recognised file types for image preview?

Is it possible to add additional file types to be recognised as images and thus trigger automatic creation of an image view when a resource is uploaded?
SVG files will preview in CKAN, but we have to manually add the image view e.g.
https://datastore.landcareresearch.co.nz/dataset/novel-yeasts-from-new-zealand-forests/resource/3812ee6b-dd45-45c9-b425-6a18375e5727
With text (for example) we can specify file format extensions to recognise as text and automatically create a text preview (ckan.preview.text_formats...). Is there an equivalent for images?
Thanks
It would only be possible by modifying the source code for your instance:
https://github.com/ckan/ckan/blob/master/ckanext/imageview/plugin.py#L9
Seems like a great idea to have the image view on a par with the text view in this regard, so I made a pull request:
https://github.com/ckan/ckan/pull/3380

Remove/disable Image Rendition Selection when adding a picture to a custom Content Type

Is it possible to remove/disable the selection of the Image Rendition when selecting a picture in a custom content type?
Any User/Contributer should not be able to choose the image Rendition because it happens programmatically in the Display Template. The Picture must always be choosen as Full Size Image!
Has anyone an idea how i can set this up?
As i remember Image Renditions are implemented using query string params so you can always ignore provided by user image rendition and override it in your display template.
I imported the picture in the Item_Custom.html Template (masterpages\Display Templates\Cotrol Web Parts\Item_Custom.html) like I did in the other Templates:
<mso:ManagedPropertyMapping msdt:dt="string">'Category Image'{Category Image}:'MyCategoryImageOWSIMGE',' .... </mso:ManagedPropertyMapping>
Then Set the JS Variable:
<!--#_
var CategoryImage = $getItemValue(ctx, "Category Image");
_#-->
And manually set the Rendition ID, no matter what was choosen by the user:
<img style="visibility: visible;" src="_#= CategoryImage =#_?RenditionID=7" id="CategoryImage" onload ... >

How do I display a dynamically resized image in Kohana without saving it?

I have an image path string stored in a database
It goes like: img/uploads/imagename.jpg
I have a controller:
$this->image = new Image($wines->image)
//this is assuming that I have a wines table with the image property
$this->image->resize(60, 250, Image::AUTO)
echo $this->image->render();
//the problem is nothing is rendered
//Is there a better way of doing this? the image path that I am passing at the Image object //instantiation is the result of a query
Don't use "echo"
Move the render to a view
You need not use the echo itself. render() itself echoes the output to the browser. Maybe, you need to use render(true), as per the document.
http://docs.kohanaphp.com/libraries/image#render
EDIT: Also be careful with the paths. If possible, use absolute paths OR preferably paths relative to your document root.

Resources