I just started learning React-Native, I have such a problem in my current project.
I am receiving Car part image from API, this image is png format, each part number is numbered in the picture, I also getting coordinates (coordinates(x,y), width, height) of each number. My aim is to give border and border color each number inside part picture
The problem is that these coordinates are calculated on a full-sized image, and do not match the image on mobile devices. Also the problem arises when enlarging the image, the existing coordinates are almost useless.
I will accept any offer which will give me the right point, Thanks
I want to achieve same result, but I have no idea how they are solving this problem into an existing project: link here
Reproduction Link: link here
import React from "react";
import { Animated, Dimensions, View, Image, Text} from "react-native";
import ImageZoom from 'react-native-image-pan-zoom';
import {useState} from "react";
const PinchableBox = () => {
const [scale, setScale] = useState('')
/* Part number, coordinates(x,y, width,height) */
let partPosition = {number:1,coordinates:[327,18,12,22]}
let calculated = partPosition.coordinates[0] / scale
console.log(calculated)
return (
<View>
<View style={{position:'relative'}}>
<ImageZoom
cropWidth={350}
cropHeight={290}
panToMove={true}
minScale={1}
maxScale={4}
imageHeight={300}
onMove={(e)=>setScale(e.scale)}
imageWidth={300}
style={{marginTop:0}}
>
<Image style={{ width: '100%', height: 300}}
source={{ uri: `https://img.parts-catalogs.com/bmw_2020_01/data/JPG/209412.png` }}
resizeMode="contain"
/>
</ImageZoom>
<Text
style={{
color:'red',
borderWidth:2,
height:partPosition.coordinates[3],
width:partPosition.coordinates[2],
position:'absolute',
transform:[{translateX:327 * (scale / 2 )},{translateY:18 * scale}]
}}
>{partPosition.number}
</Text>
</View>
</View>
);
};
export default PinchableBox;