當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript image-source.fromNativeSource函數代碼示例

本文整理匯總了TypeScript中image-source.fromNativeSource函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fromNativeSource函數的具體用法?TypeScript fromNativeSource怎麽用?TypeScript fromNativeSource使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fromNativeSource函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: calculateInSampleSize

                appModule.android.onActivityResult = (requestCode: number, resultCode: number, data: android.content.Intent) => {
                    appModule.android.onActivityResult = previousResult;

                    if (requestCode === REQUEST_IMAGE_CAPTURE && resultCode === android.app.Activity.RESULT_OK) {
                        var options = new android.graphics.BitmapFactory.Options();
                        options.inJustDecodeBounds = true;
                        android.graphics.BitmapFactory.decodeFile(tempPicturePath, options);

                        var sampleSize = calculateInSampleSize(options.outWidth, options.outHeight, reqWidth, reqHeight);

                        var finalBitmapOptions = new android.graphics.BitmapFactory.Options();
                        finalBitmapOptions.inSampleSize = sampleSize;
                        var bitmap = android.graphics.BitmapFactory.decodeFile(tempPicturePath, finalBitmapOptions);
                        var scaledSizeImage = null;
                        if (reqHeight > 0 && reqWidth > 0) {
                            if (shouldKeepAspectRatio) {

                                var common: typeof cameraCommonModule = require("./camera-common");

                                var aspectSafeSize = common.getAspectSafeDimensions(bitmap.getWidth(), bitmap.getHeight(), reqWidth, reqHeight);
                                scaledSizeImage = android.graphics.Bitmap.createScaledBitmap(bitmap, aspectSafeSize.width, aspectSafeSize.height, true);
                            }
                            else {
                                scaledSizeImage = android.graphics.Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, true);
                            }
                        }
                        else {
                            scaledSizeImage = bitmap;
                        }

                        var imageSource: typeof imageSourceModule = require("image-source");

                        resolve(imageSource.fromNativeSource(scaledSizeImage));
                    }
                };
開發者ID:ahmadissa2,項目名稱:NativeScript,代碼行數:35,代碼來源:camera.android.ts

示例2: require

                appModule.android.onActivityResult = (requestCode: number, resultCode: number, data: android.content.Intent) => {
                    appModule.android.onActivityResult = previousResult;

                    if (requestCode === REQUEST_IMAGE_CAPTURE && resultCode === android.app.Activity.RESULT_OK) {
                            var imageSource: typeof imageSourceModule = require("image-source");
                        if (saveToGallery) {
                            resolve({image:imageSource.fromFile(picturePath) ,path:picturePath});
                        } else {
                            var options = new android.graphics.BitmapFactory.Options();
                            options.inJustDecodeBounds = true;
                            android.graphics.BitmapFactory.decodeFile(picturePath, options);

                            var sampleSize = calculateInSampleSize(options.outWidth, options.outHeight, reqWidth, reqHeight);

                            var finalBitmapOptions = new android.graphics.BitmapFactory.Options();
                            finalBitmapOptions.inSampleSize = sampleSize;
                            var bitmap = android.graphics.BitmapFactory.decodeFile(picturePath, finalBitmapOptions);
                            var scaledSizeImage = null;
                            if (reqHeight > 0 && reqWidth > 0) {
                                if (shouldKeepAspectRatio) {

                                    var common: typeof cameraCommonModule = require("./camera-common");

                                    var aspectSafeSize = common.getAspectSafeDimensions(bitmap.getWidth(), bitmap.getHeight(), reqWidth, reqHeight);
                                    scaledSizeImage = android.graphics.Bitmap.createScaledBitmap(bitmap, aspectSafeSize.width, aspectSafeSize.height, true);
                                }
                                else {
                                    scaledSizeImage = android.graphics.Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, true);
                                }
                            }
                            else {
                                scaledSizeImage = bitmap;
                            }

                            var ei = new android.media.ExifInterface(picturePath);
                            var orientation = ei.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL);

                            switch (orientation) {
                                case android.media.ExifInterface.ORIENTATION_ROTATE_90:
                                    scaledSizeImage = rotateBitmap(scaledSizeImage, 90);
                                    break;
                                case android.media.ExifInterface.ORIENTATION_ROTATE_180:
                                    scaledSizeImage = rotateBitmap(scaledSizeImage, 180);
                                    break;
                                case android.media.ExifInterface.ORIENTATION_ROTATE_270:
                                    scaledSizeImage = rotateBitmap(scaledSizeImage, 270);
                                    break;
                            }

                            resolve({image:imageSource.fromNativeSource(scaledSizeImage), path:picturePath});

                        }
                    }
                };
開發者ID:TheOriginalJosh,項目名稱:NativeScript,代碼行數:54,代碼來源:camera.android.ts


注:本文中的image-source.fromNativeSource函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。