Icon or image (PNG), which is the most performative? - react-native

I'm working on a project that involves displaying a map (https://github.com/react-native-community/react-native-maps) and there are 34 possible types of picture pins (PNG) and I'd like to know which becomes more performative. Keep using these images or adopt the use of icons? Taking into account that the images have on average 10Kb
For those who do not know, converting to SVG can turn into an icon (https://github.com/oblador/react-native-vector-icons)

Related

Making only a small section of a vector drawable visible

I have a large image, based on a vector drawable xml file, and I would like to visualize only part of it in an ImageView, like this (the darker regions would be off screen):
Under user control, the image would move around (or rather, the visible part of it), very much like a Google maps app.
I can manage to dig into Android Studio but I would like to get some hint on what would be a proper approach to handle this. Is using a large xml file and clipping it appropriate or is it better drawing it on a canvas in runtime?
I played with both vector drawables and drawing on a canvas, but not enough to be sure which way to go for this or to post any code.

Expo camera real-time image analysis

I know how to take a picture with my camera using the “expo-camera” module, but I don’t know how to setup a system where it takes a photo about 10 times a second, analyses the colors in the image, to be used for tracking. Expo camera can return images as base64, so I’m guessing I would have to use that, but I don’t know to efficiently take a picture constantly and analyse it.
react-native-vision-camera might be more appropriate for what you're trying to achieve. It allows you to write frame processors to analyse frame contents.
But if you wanted to use expo-camera then you could do it the way you described, but you'd need to then find a module to take the Base64 encoded image and turn it into an array or stream of pixel values. This is likely to be very slow and use a lot of memory to run on the JS thread because each image from a standard 12MP camera is going to mean you'll be looping over an array of 12 million RGB values.

Tiled map editor cutting off edges of imported png

I started to write a small engine to render a 2d isometric map. A friend of mine made a small basic image of a train station to use example art for my engine. I tried to import the .png into tiled and create a tileset for it, to then use the information for the rendering of that house.
When I import the image, tiled cuts off the edges of the picture (see attachment "tiled .png import to tileset") on the right and bottom side. I looked into the menus and tried to find information about it but I could'nt find any helpful advice why it happens.
Another thing I find curious is the information within the .tsx file:
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.2" tiledversion="1.2.1" name="bAHNHOF" tilewidth="30"
tileheight="30" tilecount="195" columns="13">
<image source="bAHNHOF.png" width="401" height="468"/>
</tileset>
Shouldn't columns(13) multiplied by tile width(30) result in width of the imported image (i.e. 401). It only is 390 though, so roughly 11 pixels less then the original width.
I probably made a mistake somewhere or am confusing something. Maybe someone can help me?
Thanks in advance :)
Seem like whatever editor you are using wants "whole tile" sizes. This is not uncommon. Increase the size of your base image so that the X and Y align to tile size boundaries to prevent this. 30 for a tile size is also very unusual. I'd expect a power of 2 like "32" or "16".
In short, your importer is culling tiles that are not full size. I'd expect it to display a warning about image size before it did this, but who knows as you didn't state the programs.
When this goes onto whatever platform you are using, a power of 2 tile size will help as well in terms of efficiency, so consider making that change sooner rather than later as well.
Finally, often tiling is done to save memory. If, when you divide up your image into tiles (tile it), you can create identical tiles, the computer can use that knowledge to lessen the amount of memory is needed.

Custom icons on google map not drawing correctly

I'm having problems with google maps, drawing icons was working fine few weeks ago in my project. At some time the icons are very frequently drawing in partly and I don't know what is causing it. It is both happening on my development machine and production server and on all machines.
I'm only using two different icons so I know the bitmap images are not corrupt.
Here below are two sample images.
You'll get more help if you post your outputted JSON. Your gmaps JSON must not have quotes around width or height, like so: "picture":"/assets/dayhome.png","width":32,"height":37,"lat":53.5402,"lng":-113.628
Another fix is to include optimized:false which disables the html5 canvas (the squares that are cutting off the markers).
My much more detailed analysis here: Canvas Tiles Cut Off Custom Markers
Set optimized:false in your Marker options.
If optimized is true (the default), then your marker images are incorporated into the tiles. Unfortunately where markers cross tile boundaries, they are not also used on the adjacent tile, so appear to be truncated at the edge of the tile. Using optimized:false forces the icons to be placed on the map as separate DOM objects.

iOS: storing thumbnail images in Core Data

I need to take some images from the iPhone / iPad photo library from within my app and store them in a Core Data entity, and display them as small thumbnail images (48x48 pixels) in a UITableViewCell, and about 80x80 pixels in a detail UIView. I've followed the Recipes sample app, where they use UIImageJPEGRepresentation(value, 0.1) to convert to NSData and store the bytes inside Core Data, and it doesn't end up taking much space, which is good. But when retrieve the data, using UIImage *uiImage = [[UIImage alloc] initWithData:value]; and display it as a thumbnail image with "Aspect Fit", it looks terrible and grainy. I tried changing the image quality variable in the JPEG compression, but even setting it to 0.9 doesn't help.
Is that normal? Is there a better way to compress the image that doesn't cause so much grainee-ness? Since I just want to show a small thumbnail, and then a slightly bigger thumbnail, I feel Core Data would be great for storing this, since it should (theoretically) also support iCloud. But if it's going to look terrible, then I'll have to reconsider.
Two things, are you resizing the image to the right size? Have you tried UIImagePNGRepresentation()? That should compress it without losing quality.
If UIImagePNGRepresentation (which is lossless) is giving you bad images, then the problem is in your image resizing code. Core Data is just giving you what you back what you put in, so if you get bad images out, it's because you put bad images in.
Is one of your iPhone/iPad retina and the other isn't? If so, perhaps the problem is that you don't really want 48x48 pixel images, you want 48x48 point (which means you'll need 2x images 96x96 for retina quality display).