How to swtich image in phaser js? - phaser-framework

How to swtich image in phaser js?
I change profile image but its showing still same but when reload the game image has been changed

With the little details you provided, I think you're looking for Image.setTexture(key: string). This method will set the texture used by an image GameObject to that of "key".

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

How to force to show image orientation?

I'm using multer node and express to upload a image to my app. But some images shows rotate 90 degrees when it's on the client.
why is this happening?, how can I fix it?
By the way I'm using vue on the client and for the upload process, of course I use formdata
UPDATE
After research and comments from the guys above, its a EXIF problem. Any code ideas to solve this?
The behaviour you are experiencing is probably caused by the Exif Orientation metadata.
There is another question here on Stackoverflow about this problem: JS Client-Side Exif Orientation: Rotate and Mirror JPEG Images
The selected answer points to a project called Javascript-Load-Image as a possible solution, that basically means you will have to take the orientation in consideration when rendering the images to get a consistent behaviour.
Another possible alternative would be to edit/remove the orientation metadata in your backend.
Check the following resource for more information:
JPEG Image Orientation and Exif
This is most likely caused by Exif metadata (just like #Romulo suggested).
Browsers ignore Exif metadata when displaying images and that's why you're getting this behaviour.
To check that this is related to Exif take 4 pictures with different phone orientation (landscape left, landscape right, portrait, upside down). One of them will be shown properly, while the other 3 will be rotated. (Also note that if you're using the front camera, the image will also get mirrored).
Not all camera phones do this, but iOS does it consistently. The reason for this is performance. When rotation the phone the sensor also rotates and the picture taken doesn't take the rotation into consideration.
To properly show the photo, the image needs to be rotated, but if you just change the Exif metadata then you don't need to do it. Of course, any client that shows the image needs to be aware of this information (and iOS Photos and such are aware).
This has nothing to do with multer, but with the images are stored.
The bottom line is that you need to rotate the image to compensate for this.
Take a look over this npm package to adjust your image on the server side.

glide thumbnail for ImageView with fixed width but height wrap_content

I have been trying to implement a feed App like Instagram or Facebook. ImageViews have match_parent width (screen width) and wrap_content height.
The code I have used...
Glide.with(context)
.load(imageURL)
.thumbnail(0.1f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView)
;
That results into loading thumbnail first. The thumbnail is very small in size. I was expected that the thumbnail will display a faded image with the original image height.
Without thumbnail, the ImageViews do not populate any image (when loading) and then suddenly the original images comes into picture. I cannot use any place holder image as the height of the place holder image may not match the actual image to be loaded, makes it a bad user experience.
I have also tried...
Glide.with(context)
.load(imageURL)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(null)
.into(imageView)
;
But it is not working! I was wondering how the Instagram App does those fade in loading with images (with original image height)?
I have looked into various websites including the Glide Github issues and stack overflow, but unable to find any solution! I have already wasted about 6 hours of my day. What is the way out of this problem?
Use override attribute:
Glide.with(context)
.load(imageURL)
.override(18,18)
.thumbnail(0.1f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
Also as Instagram is owned by Facebook it might be the case that they use Fresco library (not sure though).

Node create image by mixing 2 images

I've got app based on google maps. Each user is one pin on it.
I want to create pin image basing on user profile photo.
What I need to do is
Resize given image to given size (50x50px)
Make this image circle
Below this image, put base pin image (png) that has place on it for circle photo
Save final image as pin photo
Final image should be png with transparency enabled.
Is there any node library that can do such things?
Imagemagick supports image composition, and node has Imagemagick bindings.
Even though, I guess you can achieve your goal via CSS only:
resize -> browser will do;
make it circle -> border-radius: 50%;
base pin image background -> background-image.

Can I Capture phone screenshot using j2me app?

I am trying to develop a wireless phone projector, wherein I will be showing phone screen on projector using a projector connected PC.
I am bit confused on how to capture screenshot of any running application in j2me.
Can you help?
Just want to capture screenshot in j2me
I'm not really sure of what you wanted to do but if you are thinking of a way for your app to get a screenshot of its screen then what I can say is that you can and cannot do it. Why you cannot do it? Say your using a canvas in creating your screen. I think there isn't a way of converting the Canvas to an Image. The Canvas is limited to just drawing itself on the phone screen. But, like what I have said earlier, you can also create a screenshot of your app screen. What you need to have is an Image object over your Canvas. Why Image? It is because the Image object can be converted to an image file. And the image file will be your screenshot. But, of course, there should be something that dynamically creates the image source for the image object on the canvas.
Image myScreen = Image.createImage(createScreen());
A method that creates the screen:
InputStream createScreen(){
//dynamically creates the source of the screen
}
You can have a screenshot using myScreen. The drawback here is that rendering is quite slow. This is possible but I think this is kind of difficult to implement.
With this snippet code you can take a "screenshot" of the Canvases in your app:
public Image getScreenShot() {
Image screenshot = Image.createImage(getWidth(), getHeight());
Graphics g = screenshot.getGraphics();
paint(g);
return Image.createImage(screenshot);
}
Add getScreenShot() to any canvas that you want "screenshot" of it.Then you can get it's RGB and convert to byte[] and pass it on the network.
References:
developer.nokia

Resources