Skip to content

Instantly share code, notes, and snippets.

View muiz6's full-sized avatar

Muhammad Muiz muiz6

View GitHub Profile
@muiz6
muiz6 / quantisation.py
Last active September 9, 2023 23:38
Image Quantisation
import numpy as np
from PIL import Image
IMG_PATH = "./assets/water.jpeg"
def quantise(pixelList, width, height):
pixels = np.array([(q(r), q(g), q(b)) for r, g, b in pixelList], dtype=np.uint8)
return pixels.reshape([height, width, 3])
@muiz6
muiz6 / ThemeUtil.java
Last active August 15, 2020 13:30
How to get color from a theme attribute with java in android.
package com.muiz6.example;
import android.content.Context;
import android.content.res.Resources;
import android.util.TypedValue;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
@muiz6
muiz6 / bitmap-example.cpp
Created June 27, 2020 12:05
Example code on how to write a bitmap file from scratch.
#include <cstdint> // for specific size integers
#include <fstream> // for file handling
using namespace std;
struct BmpHeader {
char bitmapSignatureBytes[2] = {'B', 'M'};
uint32_t sizeOfBitmapFile = 54 + 786432; // total size of bitmap file
uint32_t reservedBytes = 0;
uint32_t pixelDataOffset = 54;
} bmpHeader;