Skip to content

Instantly share code, notes, and snippets.

View chauvansang1997's full-sized avatar

Chau Van Sang chauvansang1997

View GitHub Profile
@chauvansang1997
chauvansang1997 / openCV-portait-camera-android.java
Created November 26, 2021 15:46 — forked from heaversm/openCV-portait-camera-android.java
Renders openCV's camera in portrait mode on android - to be placed in `CameraBridgeViewBase.java`
private final Matrix mMatrix = new Matrix();
private void updateMatrix() {
float mw = this.getWidth();
float mh = this.getHeight();
float hw = this.getWidth() / 2.0f;
float hh = this.getHeight() / 2.0f;
float cw = (float)Resources.getSystem().getDisplayMetrics().widthPixels; //Make sure to import Resources package
@chauvansang1997
chauvansang1997 / utilsAndroid.java
Created July 15, 2021 14:58 — forked from morenodoug/utilsAndroid.java
Adding an image to mediaStore(see in phone gallery) on Android
public static void notifyMediaStoreScanner(Context mContext, Uri cacheImageUri) throws IOException {
Uri newImageUri = createImageInMediaStore(mContext, cacheImageUri);
ContentResolver resolver = mContext
.getContentResolver();
FileInputStream input ;
FileOutputStream outputStream ;
try (ParcelFileDescriptor pfd = resolver
.openFileDescriptor(newImageUri, "w", null)) {
// Write data into the pending image.
@chauvansang1997
chauvansang1997 / ObtainImage.java
Created July 15, 2021 14:57 — forked from BenjaminDiaz/ObtainImage.java
Android - Get image from camera or gallery
public class ObtainImage {
private Uri imgUri;
/** Here goes your code where you handle the way the user chooses between getting from gallery or opening camera **/
/**
* Opens gallery to choose image.
*/
private void chooseFromGallery() {
@chauvansang1997
chauvansang1997 / custom_dropdown_button.dart
Created December 5, 2019 02:47 — forked from DhytoDev/custom_dropdown_button.dart
Flutter Custom Dropdown Button
import 'dart:math' as math;
import 'package:flutter/material.dart';
const Duration _kDropdownMenuDuration = Duration(milliseconds: 300);
const double _kMenuItemHeight = 48.0;
const double _kDenseButtonHeight = 24.0;
const EdgeInsets _kMenuItemPadding = EdgeInsets.symmetric(horizontal: 16.0);
const EdgeInsetsGeometry _kAlignedButtonPadding =
EdgeInsetsDirectional.only(start: 16.0, end: 4.0);
@chauvansang1997
chauvansang1997 / custom_dropdown_button.dart
Created December 5, 2019 02:47 — forked from DhytoDev/custom_dropdown_button.dart
Flutter Custom Dropdown Button
import 'dart:math' as math;
import 'package:flutter/material.dart';
const Duration _kDropdownMenuDuration = Duration(milliseconds: 300);
const double _kMenuItemHeight = 48.0;
const double _kDenseButtonHeight = 24.0;
const EdgeInsets _kMenuItemPadding = EdgeInsets.symmetric(horizontal: 16.0);
const EdgeInsetsGeometry _kAlignedButtonPadding =
EdgeInsetsDirectional.only(start: 16.0, end: 4.0);