inline void AlphaBlend( Uint32& p, int cr, int cg, int cb, int a, int ia ) { //888 p = R16G16B16_TO_RGB888( a * cr + ia * R32(p), a * cg + ia * G32(p), a * cb + ia * B32(p) ); }
void OnPaint(GSurface *pDC) { GRect r = GetClient(); LgiWideBorder(pDC, r, DefaultRaisedEdge); pDC->Colour(LC_MED, 24); pDC->Rectangle(&r); SysFont->Transparent(true); if (Colour->Presets.Length()) { char s[64]; SysFont->Colour(LC_BLACK, LC_MED); GDisplayString ds(SysFont, (char*)LgiLoadString(L_COLOUR_NONE, "No Colour")); ds.Draw(pDC, r.x1 + 2, r.y1 + 2); for (unsigned i=0; i<Colour->Presets.Length(); i++) { int y = r.y1 + ((i+1) * Ly); COLOUR p32 = Colour->Presets[i]; pDC->Colour(p32, 32); pDC->Rectangle(r.x1+1, y+1, r.x1+Ly-1, y+Ly-1); sprintf_s(s, sizeof(s), "%2.2X,%2.2X,%2.2X", R32(p32), G32(p32), B32(p32)); GDisplayString ds(SysFont, s); ds.Draw(pDC, r.x1 + Ly + 10, y + 2); } } }
void ExtractRgb( uint32 c, int& r, int &g, int &b ) { r = R32(c); g = G32(c); b = B32(c); }
int JpegCompressor::compressRawImage(const void * image, int width, int height, int quality, int useEffect = 0) { void * src = const_cast<void *>(image); uint8_t *yp = static_cast<uint8_t *>(src); struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPROW row_pointer[1]; uint8_t *line_buffer; int bufferlen = width*height<<1; line_buffer = (uint8_t*)calloc(width*3,1); mJpegBuffer = new uint8_t[bufferlen]; mJpegSize = 0; if(!line_buffer) { LOGE("@TEI compress_yuv_to_jpeg: line_buffer calloc failed!" ); return -1; } if (!mJpegBuffer) { free(line_buffer); return -1; } cinfo.err = jpeg_std_error (&jerr); jpeg_create_compress (&cinfo); jpeg_nf_stdio_dest(&cinfo,(char*)mJpegBuffer,&bufferlen ); cinfo.image_width = width; cinfo.image_height = height; cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults (&cinfo); jpeg_set_quality (&cinfo, quality, TRUE); jpeg_start_compress (&cinfo, TRUE); uint8_t *vp, *up,*vpos, *upos; getYuvOffsets(width, height, yp, &up, &vp); vpos=vp; upos=up; uint32_t rgb = 0xFFFFFFFF; int z = 0; while (cinfo.next_scanline < cinfo.image_height) { unsigned char *ptr = line_buffer; for (int x = 0; x < width; x += 2) { rgb = YUVToRGB32WithEffect(*yp, *up, *vp, useEffect); *ptr++ = R32(rgb); *ptr++ = G32(rgb); *ptr++ = B32(rgb); // yp += mStrides[0]; rgb = YUVToRGB32WithEffect(*yp, *up, *vp, useEffect); *ptr++ = R32(rgb); *ptr++ = G32(rgb); *ptr++ = B32(rgb); // yp += mStrides[0]; up += mStrides[1]; vp += mStrides[2]; } if (mIs420) { if (z == 0) { vp = vpos; up = upos; z++; } else { vpos = vp; upos = up; z--; } } row_pointer[0] = line_buffer; jpeg_write_scanlines (&cinfo, row_pointer, 1); } jpeg_finish_compress (&cinfo); jpeg_destroy_compress (&cinfo); free (line_buffer); mJpegSize = bufferlen; LOGD("====== Jpeg size: %d ======", mJpegSize); return 0; }