Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oliverphaser/nativescript-bitmap-factory

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oliverphaser/nativescript-bitmap-factory - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

491

index.d.ts

@@ -1,428 +0,62 @@

import Application = require("@nativescript/core/application");
import ImageSource = require('@nativescript/core/image-source');
// The MIT License (MIT)
//
// Copyright (c) Marcel Joachim Kloubert <marcel.kloubert@gmx.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
"use strict";
var BitmapFactory = require("./BitmapFactory");
var TypeUtils = require("@nativescript/core/utils/types");
/**
* Describes an object that stores ARGB color data.
*/
export interface IArgb {
/**
* Gets the alpha value.
*/
a: number;
/**
* Gets the red value.
*/
r: number;
/**
* Gets the green value.
*/
g: number;
/**
* Gets the blue value.
*/
b: number;
}
/**
* Describes bitmap data.
*/
export interface IBitmapData {
/**
* Gets the data as Base64 string.
*/
base64: string;
/**
* Gets the mime type.
*/
mime: string;
}
/**
* Describes an object that stores a font.
*/
export interface IFont {
/**
* Anti alias or not.
*/
antiAlias?: boolean;
/**
* Gets the custom forground color.
*/
color?: string | number | IArgb;
/**
* Gets the name.
*/
name?: string;
/**
* Gets the size.
*/
size?: number;
}
/**
* Options for 'makeMutable()' functon.
*/
export interface IMakeMutableOptions {
/**
* Dispose current bitmap or not.
*
* Default: (false)
*/
disposeCurrent?: boolean;
/**
* Options for handling temp data / files.
*/
temp?: {
/**
* This is only used if stradegy is 'Custom' and
* is used to define the custom temp directory.
*
* This can be a string or a native object that represents a file
* like java.lang.File on Android.
*/
directory?: any;
/**
* The stradegy.
*
* Default: Memory
*/
stradegy?: TempFileStradegy;
};
}
/**
* A 2D point.
*/
export interface IPoint2D {
/**
* Gets the X coordinate.
*/
x: number;
/**
* Gets the X coordinate.
*/
y: number;
}
/**
* Describes an object that stores a size.
*/
export interface ISize {
/**
* Gets the height.
*/
height: number;
/**
* Gets the width.
*/
width: number;
}
/**
* List of outout formats.
*/
export declare enum OutputFormat {
(function (OutputFormat) {
/**
* PNG
*/
PNG = 1,
OutputFormat[OutputFormat["PNG"] = 1] = "PNG";
/**
* JPEG
*/
JPEG = 2,
}
OutputFormat[OutputFormat["JPEG"] = 2] = "JPEG";
})(exports.OutputFormat || (exports.OutputFormat = {}));
var OutputFormat = exports.OutputFormat;
/**
* List of temp file stradegies.
*/
export declare enum TempFileStradegy {
(function (TempFileStradegy) {
/**
* Memory
*/
Memory = 1,
TempFileStradegy[TempFileStradegy["Memory"] = 1] = "Memory";
/**
* Cache directory
*/
CacheDir = 2,
TempFileStradegy[TempFileStradegy["CacheDir"] = 2] = "CacheDir";
/**
* External directory
*/
ExternalCacheDir = 3,
TempFileStradegy[TempFileStradegy["ExternalCacheDir"] = 3] = "ExternalCacheDir";
/**
* Custom directory
*/
Custom = 4,
}
TempFileStradegy[TempFileStradegy["Custom"] = 4] = "Custom";
})(exports.TempFileStradegy || (exports.TempFileStradegy = {}));
var TempFileStradegy = exports.TempFileStradegy;
/**
* Describes a bitmap.
*/
export interface IBitmap {
/**
* Get the android specific object provided by 'application' module.
*/
android: Application.AndroidApplication;
/**
* Clones that bitmap.
*
* @return {IBitmap} Cloned bitmap.
*/
clone(): IBitmap;
/**
* Crops that bitmap and returns its copy.
*
* @param {IPoint2D} [leftTop] The coordinates of the left/top corner.
* @param {ISize} [size] The size.
*
* @return {IBitmap} The cropped bitmap.
*
* @throws At least one input value is invalid.
*/
crop(leftTop?: IPoint2D | string, size?: ISize | string): IBitmap;
/**
* Gets or sets the default color.
*/
defaultColor: IPoint2D | string | number;
/**
* Disposes the bitmap. Similar to the IDisposable pattern of .NET Framework.
*
* @param {Function} [action] The action to invoke BEFORE bitmap is disposed.
* @param {T} [tag] An optional value for the action.
*
* @return {TResult} The result of the action (if defined).
*/
dispose<T, TResult>(action?: (bmp: IBitmap, tag?: T) => TResult, tag?: T): TResult;
/**
* Draws a circle.
*
* @chainable
*
* @param {number} [radius] The radius.
* @param any [center] The center coordinates.
* @param any [color] The line color.
* @param any [fillColor] The fill color.
*
* @throws At least one input value is invalid.
*/
drawCircle(radius?: number, center?: IPoint2D | string, color?: string | number | IArgb, fillColor?: string | number | IArgb): IBitmap;
/**
* Draws an arc.
*
* @chainable
*
* @param {ISize} [size] The size.
* @param {IPoint2D} [leftTop] The coordinates of the left/top corner.
* @param {number} [startAngle] The starting angle (in degrees) where the arc begins.
* @param {number} [sweepAngle] The sweep angle (in degrees) measured clockwise.
* @param any [color] The line color.
* @param any [fillColor] The fill color.
*
* @throws At least one input value is invalid.
*/
drawArc(size?: ISize | string, leftTop?: IPoint2D | string, startAngle?: number, sweepAngle?: number, color?: string | number | IArgb, fillColor?: string | number | IArgb): IBitmap;
/**
* Draws a line.
*
* @chainable
*
* @param {IPoint2D} start The coordinates of the start point.
* @param {IPoint2D} end The coordinates of the end point.
* @param {IArgb} [color] The color to use. Default is black.
*
* @throws At least one input value is invalid.
*/
drawLine(start: IPoint2D | string, end: IPoint2D | string, color?: string | number | IArgb): IBitmap;
/**
* Draws an oval circle.
*
* @chainable
*
* @param {ISize} [size] The size.
* @param {IPoint2D} [leftTop] The coordinates of the left/top corner.
* @param {IArgb} [color] The line color.
* @param {IArgb} [fillColor] The fill color.
*
* @throws At least one input value is invalid.
*/
drawOval(size?: ISize | string, leftTop?: IPoint2D | string, color?: string | number | IArgb, fillColor?: string | number | IArgb): IBitmap;
/**
* Draws a rectangle.
*
* @chainable
*
* @param {ISize} [size] The size.
* @param {IPoint2D} [leftTop] The coordinates of the left/top corner.
* @param {IArgb} [color] The line color.
* @param {IArgb} [fillColor] The fill color.
*
* @throws At least one input value is invalid.
*/
drawRect(size?: ISize | string, leftTop?: IPoint2D | string, color?: string | number | IArgb, fillColor?: string | number | IArgb): IBitmap;
/**
* Gets the color of a point.
*
* @param {IPoint2D} [coordinates] The coordinates of the point.
*
* @return {IArgb} The color.
*
* @throws At least one input value is invalid.
*/
getPoint(coordinates?: IPoint2D | string): IArgb;
/**
* Gets the height of the bitmap.
*/
height: number;
/**
* Get the iOS specific object provided by 'application' module.
*/
ios: Application.iOSApplication;
/**
* Inserts another image into that bitmap.
*
* @chainable
*
* @param {IBitmap} other The other image.
* @param {IPoint2D} [leftTop] The coordinates of the left/top corner.
*
* @throws At least one input value is invalid.
*/
insert(other: any, leftTop?: IPoint2D | string): IBitmap;
/**
* Gets if the object has been disposed or not.
*/
isDisposed: boolean;
/**
* Gets the native platform specific object that represents that bitmap.
*/
nativeObject: any;
/**
* Normalizes a color value.
*
* @param any value The input value.
*
* @return {IArgb} The output value.
*
* @throws At least one input value is invalid.
*/
normalizeColor(value: string | number | IArgb): IArgb;
/**
* Creates a copy of that bitmap with a new size.
*
* @param {ISize} newSize The new size.
*
* @return {IBitmap] The new bitmap.
*/
resize(newSize: ISize | string): IBitmap;
/**
* Resizes that image by defining a new height by keeping ratio.
*
* @param {Number} newHeight The new height.
*
* @return {IBitmap} The resized image.
*/
resizeHeight(newHeight: number): IBitmap;
/**
* Resizes that image by defining a new (maximum) size by keeping ratio.
*
* @param {Number} maxSize The maximum width or height.
*
* @return {IBitmap} The resized image.
*/
resizeMax(maxSize: number): IBitmap;
/**
* Resizes that image by defining a new width by keeping ratio.
*
* @param {Number} newWidth The new width.
*
* @return {IBitmap} The resized image.
*/
resizeWidth(newWidth: number): IBitmap;
/**
* Rotates the image.
*
* @param {number} [degrees] The number of degrees to rotate. Default: 90.
*
* @return {IBitmap} The rotated image.
*/
rotate(degrees?: number): IBitmap;
/**
* Sets a pixel / point.
*
* @chainable
*
* @param {IPoint2D} [coordinates] The coordinate where to draw the point.
* @param {IArgb} [color] The color of the point.
*
* @throws At least one input value is invalid.
*/
setPoint(coordinates?: IPoint2D | string, color?: string | number | IArgb): IBitmap;
/**
* Gets the size.
*/
size: ISize;
/**
* Converts that image to a Base64 string.
*
* @param {OutputFormat} format The output format. Default is: PNG
* @param {Number} quality A value between 0 (0%) and 100 (100%) for the output quality.
*
* @return {String} The bitmap a Base64 string.
*
* @throws At least one input value is invalid.
*/
toBase64(format?: OutputFormat, quality?: number): string;
/**
* Converts that image to a data URL.
*
* @param {OutputFormat} format The output format. Default is: PNG
* @param {Number} quality A value between 0 (0%) and 100 (100%) for the output quality.
*
* @return {String} The bitmap as data url.
*
* @throws At least one input value is invalid.
*/
toDataUrl(format?: OutputFormat, quality?: number): string;
/**
* Returns that image as ImageSource.
*
* @return {ImageSource} The bitmap as ImageSource.
*/
toImageSource(): ImageSource.ImageSource;
/**
* Converts that image to an object.
*
* @param {OutputFormat} format The output format. Default is: PNG
* @param {Number} quality A value between 0 (0%) and 100 (100%) for the output quality.
*
* @return {IBitmapData} The bitmap as object.
*
* @throws At least one input value is invalid.
*/
toObject(format?: OutputFormat, quality?: number): IBitmapData;
/**
* Writes a text.
*
* @chainable
*
* @param {any} txt The text /value to write.
* @param {IPoint2D} [leftTop] The left/top corner.
* @param {IFont} [font] The custom font to use.
*
* @throws At least one input value is invalid.
*/
writeText(txt: any, leftTop?: IPoint2D | string, font?: IFont | string): IBitmap;
/**
* Gets the width of the bitmap.
*/
width: number;
}
/**
* Additional options for creating a bitmap.
*/
export interface ICreateBitmapOptions {
/**
* iOS specific options.
*/
ios?: {
/**
* Let iOS auto release the underlying CGImage (true) or let
* the object call CGImageRelease() manually (false).
*
* Default: (true)
*/
autoRelease?: boolean;
};
}
/**
* Returns a value as bitmap object.

@@ -437,3 +71,11 @@ *

*/
export declare function asBitmap(v: any, throwException?: boolean): IBitmap;
function asBitmap(v, throwException) {
if (throwException === void 0) { throwException = true; }
var result = BitmapFactory.asBitmapObject(v);
if (throwException && (false === result)) {
throw "No valid value for a bitmap!";
}
return result;
}
exports.asBitmap = asBitmap;
/**

@@ -448,3 +90,15 @@ * Creates a new bitmap.

*/
export declare function create(width: number, height?: number, opts?: ICreateBitmapOptions): IBitmap;
function create(width, height, opts) {
if (TypeUtils.isNullOrUndefined(height)) {
height = width;
}
if (arguments.length < 3) {
opts = getDefaultOptions();
}
if (TypeUtils.isNullOrUndefined(opts)) {
opts = {};
}
return BitmapFactory.createBitmap(width, height, opts);
}
exports.create = create;
/**

@@ -455,3 +109,10 @@ * Returns the default options for creating a new bitmap.

*/
export declare function getDefaultOptions(): ICreateBitmapOptions;
function getDefaultOptions() {
var opts = BitmapFactory.getDefaultOpts();
if (!opts) {
opts = {};
}
return opts;
}
exports.getDefaultOptions = getDefaultOptions;
/**

@@ -467,3 +128,12 @@ * Makes a (native) image / bitmap mutable.

*/
export declare function makeMutable(v: any, opts?: IMakeMutableOptions): any;
function makeMutable(v, opts) {
if (TypeUtils.isNullOrUndefined(v)) {
return v;
}
if (!opts) {
opts = {};
}
return BitmapFactory.makeBitmapMutable(v, opts);
}
exports.makeMutable = makeMutable;
/**

@@ -474,2 +144,9 @@ * Sets the default options for creating a new bitmap.

*/
export declare function setDefaultOptions(opts: ICreateBitmapOptions): void;
function setDefaultOptions(opts) {
if (!opts) {
opts = {};
}
BitmapFactory.setDefaultOpts(opts);
}
exports.setDefaultOptions = setDefaultOptions;
//# sourceMappingURL=index.js.map

2

index.js

@@ -24,3 +24,3 @@ // The MIT License (MIT)

var BitmapFactory = require("./BitmapFactory");
var TypeUtils = require("@nativescript/core/utils/types");
var TypeUtils = require("utils/types");
/**

@@ -27,0 +27,0 @@ * List of outout formats.

{
"name": "@oliverphaser/nativescript-bitmap-factory",
"version": "1.0.8",
"version": "1.0.9",
"description": "A NativeScript module for creating and manipulating bitmap images. Forked from mkloubert and updated for NativeScript 8 with fixed iOS crop bug.",

@@ -14,4 +14,4 @@ "main": "bitmap-factory",

"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
"access": "public",
"registry": "https://registry.npmjs.org/"
},

@@ -71,8 +71,8 @@ "repository": {

"@nativescript/ios": "~8.0.0",
"typescript": "~4.1.3",
"prompt": "^1.0.0",
"rimraf": "^2.6.3",
"tslint": "^5.12.1"
"typescript": "~4.1.3",
"prompt": "^1.0.0",
"rimraf": "^2.6.3",
"tslint": "^5.12.1"
},
"bootstrapper": "nativescript-plugin-seed"
}

@@ -1,2 +0,2 @@

[npm]: https://img.shields.io/npm/v/nativescript-eventify.svg?color=949393
[npm]: https://img.shields.io/npm/v/@oliverphaser/nativescript-bitmap-factory.svg?color=949393
[apple]: https://img.shields.io/badge/apple-%E2%9C%93-949393.svg?logo=apple&logoColor=white

@@ -6,3 +6,3 @@ [android]: https://img.shields.io/badge/android-%E2%9C%93-949393.svg?logo=android&logoColor=white

[![npm]](https://www.npmjs.com/package/nativescript-eventify)
[![npm]](https://www.npmjs.com/package/@oliverphaser/nativescript-bitmap-factory)
![apple]

@@ -23,3 +23,3 @@ ![android]

The original module is part of [nativescript-toolbox](https://github.com/mkloubert/nativescript-toolbox).
The originial module is part of [nativescript-toolbox](https://github.com/mkloubert/nativescript-toolbox).

@@ -26,0 +26,0 @@ ## Platforms

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc