PC SOFT
DEPOT EN LIGNE
POUR WINDEVWEBDEV ET WINDEV MOBILE

WM Foods - Exemplo com Código OOP Classes e Código Java
Publié par Boller
dans la catégorie Outils
Nouveautés



Description
WM Foods - Exemplo com Código OOP Classes e Código Java

Telas

Windows
WIN_About
Controls
Procedures
MobileWinAdaptSize
Properties
WIN_EditProp
WIN_Scan
Controls
Procedures
Scan
Properties
Variables
WIN_Settings
Controls
Procedures
RefreshLPR
ValidateInput
Properties
Reports
Queries
Classes
CCookie
Members
Properties
AnalyzeCookie
Destructor_
Manufacturer
ReadCookie
Procedures
COL_JAVA
ProcessJavaPhoto
SET_OpenFoodFacts
Constants
Global variables
Types
CallbackAddProduct
CallbackUnknownProduct
CallbackUpdateProp
CallbackWS
CallbackWSAddition
CallbackWSIdentification
CallWS_FindProduct
CallWSAddProduct
CallWSLogin


------------------------------------------------------------------------

// Gives the image rotation
import android.media.ExifInterface;
import java.lang.Exception;
import android.graphics.*;
import android.util.Log;
import java.io.FileOutputStream;

public static boolean ProcessJavaPhoto(String sPhoto, int nMaxSize){
int nRotation = 0;
boolean res = false;

try{
ExifInterface m_exif = new ExifInterface(sPhoto);
nRotation = (int)exifOrientationToDegrees(m_exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_NORMAL));

// BITMAP
BitmapFactory.Options bounds = new BitmapFactory.Options();
// Reduces the size
Bitmap sourceBitmap = BitmapFactory.decodeFile(sPhoto,bounds);

if (sourceBitmap == null){
return false;
}

// Rotation
Matrix matrix = new Matrix();
if (nRotation > 0) {
matrix.preRotate(nRotation);
}

// resizing
int width = sourceBitmap.getWidth();
int height = sourceBitmap.getHeight();
int newWidth;
int newHeight;
if (width > height){
newWidth = nMaxSize;
newHeight = (int) nMaxSize * height / width;
}
else{
newHeight = nMaxSize;
newWidth = (int) nMaxSize * width / height;
}
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
matrix.postScale(scaleWidth, scaleHeight);


// Create the new bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, width, height, matrix, true);
sourceBitmap.recycle();

if (resizedBitmap == null){
return false;
}

// Save
FileOutputStream out = new FileOutputStream(sPhoto);
res = resizedBitmap.compress(Bitmap.CompressFormat.JPEG , 100, out);
resizedBitmap.recycle();

resizedBitmap = null;
sourceBitmap = null;

return res;
}
catch(Exception e) {
Log.e("MB",e.toString());
return false;
}

}

public static float exifOrientationToDegrees(int exifOrientation) {
if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
return 90;
} else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
return 180;
} else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
return 270;
}
return 0;
}

-----------------------------------------------------------------------

Illustrations, copies d'écran
none
none
Avis des utilisateurs
(Pour noter la ressource, cliquez sur Ecrire un avis)
Aucun avis ou commentaire ? Soyez le premier !