You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -230,6 +230,14 @@ The [Typescript typings](https://github.com/jtlapp/gifwrap/blob/master/index.d.t
230
230
231
231
232
232
233
+
*[GifFrame](#GifFrame)
234
+
235
+
*[new GifFrame()](#new_GifFrame_new)
236
+
237
+
*[.getPalette()](#GifFrame+getPalette)
238
+
239
+
240
+
233
241
*[GifUtil](#GifUtil)
234
242
235
243
*[.cloneFrames(frames)](#GifUtil.cloneFrames)
@@ -326,18 +334,6 @@ Copy a square portion of this image into another image.
326
334
Fills the image with a single color.
327
335
328
336
**Returns**: [<code>BitmapImage</code>](#BitmapImage) - The present image to allow for chaining.
329
-
<aname="BitmapImage+getPalette"></a>
330
-
331
-
### *bitmapImage*.getPalette()
332
-
Get a summary of the colors found within the image. The return value is an object of the following form:
333
-
334
-
Property | Description
335
-
--- | ---
336
-
colors | An array of all the opaque colors found within the image. Each color is given as an RGB number of the form 0xRRGGBB. The array is sorted by increasing number. Will be an empty array when the image is completely transparent.
337
-
usesTransparency | boolean indicating whether there are any transparent pixels within the image. A pixel is considered transparent if its alpha value is 0x00.
338
-
indexCount | The number of color indexes required to represent this palette of colors. It is equal to the number of opaque colors plus one if the image includes transparency.
339
-
340
-
**Returns**: <code>object</code> - An object representing a color palette as described above.
341
337
<aname="BitmapImage+getRGBA"></a>
342
338
343
339
### *bitmapImage*.getRGBA(x, y)
@@ -347,9 +343,15 @@ indexCount | The number of color indexes required to represent this palette of c
347
343
| x | <code>number</code> | x-coord of pixel |
348
344
| y | <code>number</code> | y-coord of pixel |
349
345
350
-
Gets the RGBA number of the pixel at the given coordinate in the form 0xRRGGBBAA, where AA is the alpha value, with 0x00 being transparent.
346
+
Gets the RGBA number of the pixel at the given coordinate in the form 0xRRGGBBAA, where AA is the alpha value, with alpha 0x00 encoding to transparency in GIFs.
351
347
352
348
**Returns**: <code>number</code> - RGBA of pixel in 0xRRGGBBAA form
349
+
<aname="BitmapImage+getRGBASet"></a>
350
+
351
+
### *bitmapImage*.getRGBASet()
352
+
Gets a set of all RGBA colors found within the image.
353
+
354
+
**Returns**: <code>Set</code> - Set of all RGBA colors that the image contains.
353
355
<aname="BitmapImage+greyscale"></a>
354
356
355
357
### *bitmapImage*.greyscale()
@@ -429,6 +431,18 @@ See the base class BitmapImage for a discussion of all parameters but `options`
429
431
430
432
Provide a `frame` to the constructor to create a clone of the provided frame. The new frame includes a copy of the provided frame's pixel data so that each can subsequently be modified without affecting each other.
431
433
434
+
<aname="GifFrame+getPalette"></a>
435
+
436
+
### *gifFrame*.getPalette()
437
+
Get a summary of the colors found within the frame. The return value is an object of the following form:
438
+
439
+
Property | Description
440
+
--- | ---
441
+
colors | An array of all the opaque colors found within the frame. Each color is given as an RGB number of the form 0xRRGGBB. The array is sorted by increasing number. Will be an empty array when the image is completely transparent.
442
+
usesTransparency | boolean indicating whether there are any transparent pixels within the frame. A pixel is considered transparent if its alpha value is 0x00.
443
+
indexCount | The number of color indexes required to represent this palette of colors. It is equal to the number of opaque colors plus one if the image includes transparency.
444
+
445
+
**Returns**: <code>object</code> - An object representing a color palette as described above.
Copy file name to clipboardExpand all lines: src/bitmapimage.js
+16-43Lines changed: 16 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -138,49 +138,7 @@ class BitmapImage {
138
138
}
139
139
140
140
/**
141
-
* Get a summary of the colors found within the image. The return value is an object of the following form:
142
-
*
143
-
* Property | Description
144
-
* --- | ---
145
-
* colors | An array of all the opaque colors found within the image. Each color is given as an RGB number of the form 0xRRGGBB. The array is sorted by increasing number. Will be an empty array when the image is completely transparent.
146
-
* usesTransparency | boolean indicating whether there are any transparent pixels within the image. A pixel is considered transparent if its alpha value is 0x00.
147
-
* indexCount | The number of color indexes required to represent this palette of colors. It is equal to the number of opaque colors plus one if the image includes transparency.
148
-
*
149
-
* @return {object} An object representing a color palette as described above.
150
-
*/
151
-
152
-
getPalette(){
153
-
// returns with colors sorted low to high
154
-
constcolorSet=newSet();
155
-
constbuf=this.bitmap.data;
156
-
leti=0;
157
-
letusesTransparency=false;
158
-
while(i<buf.length){
159
-
if(buf[i+3]===0){
160
-
usesTransparency=true;
161
-
}
162
-
else{
163
-
// can eliminate the bitshift by starting one byte prior
* Gets the RGBA number of the pixel at the given coordinate in the form 0xRRGGBBAA, where AA is the alpha value, with 0x00 being transparent.
141
+
* Gets the RGBA number of the pixel at the given coordinate in the form 0xRRGGBBAA, where AA is the alpha value, with alpha 0x00 encoding to transparency in GIFs.
184
142
*
185
143
* @param {number} x x-coord of pixel
186
144
* @param {number} y y-coord of pixel
@@ -192,6 +150,21 @@ class BitmapImage {
192
150
returnthis.bitmap.data.readUInt32BE(bi);
193
151
}
194
152
153
+
/**
154
+
* Gets a set of all RGBA colors found within the image.
155
+
*
156
+
* @return {Set} Set of all RGBA colors that the image contains.
157
+
*/
158
+
159
+
getRGBASet(){
160
+
constrgbaSet=newSet();
161
+
constbuf=this.bitmap.data;
162
+
for(letbi=0;bi<buf.length;bi+=4){
163
+
rgbaSet.add(buf.readUInt32BE(bi,true));
164
+
}
165
+
returnrgbaSet;
166
+
}
167
+
195
168
/**
196
169
* Converts the image to greyscale using inferred Adobe metrics.
Copy file name to clipboardExpand all lines: src/gifframe.js
+42Lines changed: 42 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,48 @@ class GifFrame extends BitmapImage {
62
62
this.interlaced=options.interlaced||false;
63
63
}
64
64
}
65
+
66
+
/**
67
+
* Get a summary of the colors found within the frame. The return value is an object of the following form:
68
+
*
69
+
* Property | Description
70
+
* --- | ---
71
+
* colors | An array of all the opaque colors found within the frame. Each color is given as an RGB number of the form 0xRRGGBB. The array is sorted by increasing number. Will be an empty array when the image is completely transparent.
72
+
* usesTransparency | boolean indicating whether there are any transparent pixels within the frame. A pixel is considered transparent if its alpha value is 0x00.
73
+
* indexCount | The number of color indexes required to represent this palette of colors. It is equal to the number of opaque colors plus one if the image includes transparency.
74
+
*
75
+
* @return {object} An object representing a color palette as described above.
76
+
*/
77
+
78
+
getPalette(){
79
+
// returns with colors sorted low to high
80
+
constcolorSet=newSet();
81
+
constbuf=this.bitmap.data;
82
+
leti=0;
83
+
letusesTransparency=false;
84
+
while(i<buf.length){
85
+
if(buf[i+3]===0){
86
+
usesTransparency=true;
87
+
}
88
+
else{
89
+
// can eliminate the bitshift by starting one byte prior
0 commit comments