Skip to content

Instantly share code, notes, and snippets.

View sunjun's full-sized avatar
🏠
Working from home

Sun Jun sunjun

🏠
Working from home
  • Jinan, Shandong
View GitHub Profile
ui->setupUi(this);
QDesktopWidget *desktop = QApplication::desktop();
QRect screen = desktop->screenGeometry();
int screenWidth = screen.width();
int screenHeight = screen.height();
this->setFixedSize(screenWidth, screenHeight);
QRect r = ui->label->geometry();
r.setWidth(screenWidth);
r.setCoords(0,screenHeight/2, screenWidth, screenHeight/2+20);
// r.adjust(0,screenHeight/2, screenWidth, screenHeight/2+20);
@sunjun
sunjun / save_packet_to_disk
Created March 12, 2015 08:44
save AVPacket from mem to disk and then read back
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
static FILE *open_file_write(const char *file);
static FILE *open_file_read(const char *file);
static size_t write_packt_to_file(AVPacket *packet, FILE *file);
static size_t read_packt_from_file(AVPacket *packet, FILE *file);
static void close_file(FILE *file);
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, const char *tag)
@sunjun
sunjun / Rotate
Created December 24, 2014 08:09
relayout when UIDeviceOrientationDidChangeNotification fired
- (CGRect)getScreenFrameForCurrentOrientation {
return [self getScreenFrameForOrientation:[UIApplication sharedApplication].statusBarOrientation];
}
- (CGRect)getScreenFrameForOrientation:(UIInterfaceOrientation)orientation {
UIScreen *screen = [UIScreen mainScreen];
CGRect fullScreenRect = screen.bounds;
BOOL statusBarHidden = [UIApplication sharedApplication].statusBarHidden;