Skip to content

Instantly share code, notes, and snippets.

View animsh's full-sized avatar
🚀
Wubba Lubba dub-dub

Sagar More animsh

🚀
Wubba Lubba dub-dub
View GitHub Profile
@animsh
animsh / player-seekbar-marker.html
Created December 3, 2023 08:19
video segment 100xdevs challenge
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.11.7/video-js.min.css"
rel="stylesheet"
/>
@animsh
animsh / PickDominantColorFromBitmap.java
Created December 19, 2020 19:57
Pick dominant color from bitmap
public static int getDominantColor(Bitmap bitmap) {
if (bitmap == null) {
return Color.TRANSPARENT;
}
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int size = width * height;
int pixels[] = new int[size];
//Bitmap bitmap2 = bitmap.copy(Bitmap.Config.ARGB_4444, false);
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
@animsh
animsh / PickDominantColor.java
Created December 19, 2020 19:49 — forked from KKorvin/PickDominantColor.java
How to pick dominant color from image on Android. Palette Google library used.
// Don't forget to add Palette library to your build.gradle
// compile 'com.android.support:palette-v7:+'
public static int getDominantColor(Bitmap bitmap) {
List<Palette.Swatch> swatchesTemp = Palette.from(bitmap).generate().getSwatches();
List<Palette.Swatch> swatches = new ArrayList<Palette.Swatch>(swatchesTemp);
Collections.sort(swatches, new Comparator<Palette.Swatch>() {
@Override
public int compare(Palette.Swatch swatch1, Palette.Swatch swatch2) {
return swatch2.getPopulation() - swatch1.getPopulation();