XTL
XTL

Reputation: 1452

Via math formula get coords(pixels) of Low Resolution Bitmap and Put them into same location to High Resolution bitmap Android

So i making image from camera,via native API. The problem is that,i also have an algorithms to compute some stuff(with bitmap) and problem comes,when resolution is too high(for e.g. 3000x2500),because i need wait too much time.

So first what comes in my mind,its like a workaround:

  1. Convert from source bitmap to low-resolution(for e.g. 600x800).
  2. Work with this low-resolution bitmap(computing some stuff and calculate coords,that are located on this low-resolution bitmap).
  3. Get exact pixel coords and via some Math formula(that calculates width/heights or pixels?) put them into same place,but on source bitmap(with high resolution).

So how can i achieve this part? I think it's possible,but cant understand what exactly need to do.
Thanks!

Upvotes: 0

Views: 120

Answers (2)

Prizoff
Prizoff

Reputation: 4575

OK, that is what you need

assuming you have computed some x, y values for you low res image:

int lowResX, lowResY;

Than for converting them to the hi res:

double scaleRatio = hiResImageWidth / lowResImageWidth; //be sure to use here double or float values as the result of integer division will be int, and not the double/float!
int hiResX = (int) (lowResX * scaleRatio);
int hiResY = (int) (lowResY * scaleRatio);

That's all

Upvotes: 1

Xavier Falempin
Xavier Falempin

Reputation: 1206

If you know the x,y position in your w,h bitmap then the X,Y you are looking for in your W,H bitmap are just simple ratios

x/w = X/W which you can solve easily : X = x * W/w

Similarly you get Y = y * H/h

Upvotes: 1

Related Questions