0

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!

XTL
  • 1,452
  • 2
  • 17
  • 40
  • Dont understand who downvote this. Tell me what is wrong and ill modify. – XTL Nov 05 '15 at 08:38
  • If you know how to convert resolutions, use your algorithms, etc.. than what is the problem with simple converting the coordinates by simply multiplying them by scale value? Or just ask your question more specific... What is your input exactly and what should be your output? – Prizoff Nov 05 '15 at 08:41
  • Which part is a problem for you ? converting your bitmap to low-resolution or getting the pixel position in the large bitmap with a ratio ? – Xavier Falempin Nov 05 '15 at 08:42
  • @Prizoff how to get this scale value? Ratio = LowResolutionBitmap.Width / HighResolutionBitmap.Width ? And after that,i need to multiplying this ratio on coordinate,what i got from low resolution ? PS moi input High resolution izobrajenie,moi output toje high resolution izobrajenie,no predvaritelino,ia ispoliziu spetsialinii algoritm na low-resolution izobrajenii,vo izbejanii dolgih zatrat na vi4eslenie. – XTL Nov 05 '15 at 08:46
  • @XavierFalempin "getting the pixel position in large bitmap with ratio" - yeap,that moment! So its correct : Ratio = Height or Width of low resolution / Source(high resolution) Height or Width ? – XTL Nov 05 '15 at 08:46
  • @Prizoff zdarova :). Esli esti vremea,gleani eto http://stackoverflow.com/questions/34052186/how-to-draw-portion-of-bitmap-via-canvas-drawbitmap i eto http://stackoverflow.com/questions/34062615/how-to-get-correct-coordsevent-getx-event-gety-of-object-with-ontouchlis . Blagodariu :) – XTL Dec 09 '15 at 08:43

2 Answers2

1

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

Xavier Falempin
  • 1,186
  • 7
  • 19
  • so i can get ratio via this formula: Ratio = SourceWidth / LowResWidth. But thanks for the reply! – XTL Nov 05 '15 at 09:12
1

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

Prizoff
  • 4,486
  • 4
  • 41
  • 69