[LG Optimus 3D] troopii:
i got stucked on hdr part and need your help.

i want to add a preview for hdr that we can remove the shaking of the 3 pics manual. so that we get a hdr pic wihout ghosting.

for that i need the dif of the 2 pics from the basepic and the new width and height for cropping at the right size.

for the bAse pic and the pic with the biggest X and Y its working but im to stupid to get the right postion for the pic with the smallest X and Y.

FirstPicHandler ist the pic with the most brightness.

SecondPicHandler is the pic with the lowest brightness.

basePicHandler ist the pic with the normal brightness.

overlayView.leftMargineFirstPic is the X postion relative to the basePicHandler.X

overlayView.topMargineFirstPic is the Y postion relative to the basePicHandler.Y

so if we have a pic with true size:

X = 0

Y = 0

width = 1000

height = 1000

the first pic has a diff of:

X = -10 moved to leftside

Y = 10 moved to bottom

the new image will have cropped:

x = 10

width = 990;

y = 0

height = 990;

the second pic has a dif of:

x = 20 moved to right side

y = -20 moved to top

the new image will have cropped:

x = 0

width = 980;

Y = 20

height = 980;

so the base pic has the cropped size:

x = 10 from first pic

width = 980 from smallest width

y = 20 from second pic

height = 980; from smallest height,

and now i need the new diff for the two others pics based one the basepic cropped. thats where i got stuck

//get the new width and hight of the first and second pic throug the moved margines
FirstPicHandler = new BitmapHandler(uris[0]);
FirstPicHandler.AddX(overlayView.leftMargineFirstPic);
FirstPicHandler.AddY(overlayView.topMargineFirstPic);
SecondPicHandler = new BitmapHandler(uris[2]);
SecondPicHandler.AddX(overlayView.leftMargineSecondPic);
SecondPicHandler.AddY(overlayView.topMargineSecondPic);

//create the new size of the basepic based on the biggest values
basePicHandler = new BitmapHandler(uris[1]);
if (FirstPicHandler.X >= SecondPicHandler.X)
{
basePicHandler.X = FirstPicHandler.X;
}
else
{
basePicHandler.X = SecondPicHandler.X;
}
if (FirstPicHandler.Y >= SecondPicHandler.Y)
{
basePicHandler.Y = FirstPicHandler.Y;
}
else
{
basePicHandler.Y = SecondPicHandler.Y;
}
//set new width for alls pics
if (FirstPicHandler.Width >= SecondPicHandler.Width)
{
basePicHandler.Width = SecondPicHandler.Width;
FirstPicHandler.Width = SecondPicHandler.Width;
}
else
{
basePicHandler.Width = FirstPicHandler.Width;
SecondPicHandler.Width = FirstPicHandler.Width;
}
//set new hight for all pics
if (FirstPicHandler.Height >= SecondPicHandler.Height)
{
basePicHandler.Height = SecondPicHandler.Height;
FirstPicHandler.Height = SecondPicHandler.Height;
}
else
{
basePicHandler.Height = FirstPicHandler.Height;
SecondPicHandler.Height = FirstPicHandler.Height;
}
//save pictures with new croped size
try
{
Bitmap newFirstPic = Bitmap.createBitmap(BitmapFactory.decodeFile(uris[0].getPath()), FirstPicHandler.X, FirstPicHandler.Y, FirstPicHandler.Width, FirstPicHandler.Height);
saveBitmap(uris[0].getPath(), newFirstPic);
Bitmap newSecondPic = Bitmap.createBitmap(BitmapFactory.decodeFile(uris[2].getPath()), SecondPicHandler.X, SecondPicHandler.Y, SecondPicHandler.Width, SecondPicHandler.Height);
saveBitmap(uris[2].getPath(), newSecondPic);
Bitmap newBaseImage = Bitmap.createBitmap(BitmapFactory.decodeFile(uris[1].getPath()), basePicHandler.X, basePicHandler.Y, basePicHandler.Width, basePicHandler.Height);
saveBitmap(uris[1].getPath(), newBaseImage);
}
catch (OutOfMemoryError ex)
{
Toast.makeText(this, "OutOFMEMORY SUCKS AS HELL", 10).show();

ex.printStackTrace();
}

Code of BitmapHandlerClass

/**
* Created by troop on 08.11.13.
*/
public class BitmapHandler
{
public Uri filePath;

public int X;
public int Y;
public int Width;
public int Height;

public BitmapHandler(Uri filePath)
{
this.filePath = filePath;
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath.getPath(), o);
X = 0;
Y = 0;
Width = o.outWidth;
Height = o.outHeight;
}

public void AddX(int x)
{
if (x >= 0)
{
//X += x;
Width -= x;
}
else
{
X -= x;
Width += x;
}
}

public void AddY(int y)
{
if (y >= 0)
{
//Y += y;
Height -= y;
}
else
{
Y -= y;
Height += y;
}
}

if anyone can tell me what im doing wrong, it would be great and i can release the hdr part ;D