func Encode(w io.Writer, m image.Image, o *Options) error { quality := 75 if o != nil { quality = o.Quality } var cinfo C.struct_jpeg_compress_struct var jerr C.struct_jpeg_error_mgr var workBuf *C.uchar var workBufLen C.ulong cinfo.err = C.jpeg_std_error(&jerr) C.jpeg_CreateCompress(&cinfo, C.JPEG_LIB_VERSION, C.size_t(unsafe.Sizeof(cinfo))) C.jpeg_mem_dest(&cinfo, &workBuf, &workBufLen) bounds := m.Bounds() cinfo.image_width = C.JDIMENSION(bounds.Dx()) cinfo.image_height = C.JDIMENSION(bounds.Dy()) cinfo.input_components = 3 cinfo.in_color_space = C.JCS_RGB C.jpeg_set_defaults(&cinfo) C.jpeg_set_quality(&cinfo, C.int(quality), C.boolean(1)) C.jpeg_start_compress(&cinfo, C.boolean(1)) rowBuf := make([]byte, cinfo.image_width*3) for cinfo.next_scanline < cinfo.image_height { for x := 0; x < int(cinfo.image_width); x += 1 { r, g, b, _ := m.At(x, int(cinfo.next_scanline)).RGBA() rowBuf[x*3] = byte(r >> 8) rowBuf[x*3+1] = byte(g >> 8) rowBuf[x*3+2] = byte(b >> 8) } rowPointer := C.JSAMPROW(unsafe.Pointer(&rowBuf[0])) C.jpeg_write_scanlines(&cinfo, &rowPointer, 1) } C.jpeg_finish_compress(&cinfo) C.jpeg_destroy_compress(&cinfo) outBs := C.GoBytes(unsafe.Pointer(workBuf), C.int(workBufLen)) w.Write(outBs) C.free(unsafe.Pointer(workBuf)) return nil }
func (def *defLob) define(position int, charsetForm C.ub1, sqlt C.ub2, gct GoColumnType, rset *Rset) error { def.rset = rset def.gct = gct def.sqlt = sqlt def.charsetForm = charsetForm def.ociLobLocator = nil r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.ociLobLocator), //void *valuep, C.LENGTH_TYPE(unsafe.Sizeof(def.ociLobLocator)), //sb8 value_sz, sqlt, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, nil, //ub2 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r != C.OCI_SUCCESS { return def.rset.stmt.ses.srv.env.ociError() } prefetchLength := C.boolean(C.TRUE) return def.rset.stmt.ses.srv.env.setAttr(unsafe.Pointer(def.ocidef), C.OCI_HTYPE_DEFINE, unsafe.Pointer(&prefetchLength), 0, C.OCI_ATTR_LOBPREFETCH_LENGTH) }
func loop() { C.c_Loop(C.CString("PoEPricer "+strconv.FormatFloat(VERSION, 'f', 2, 64)), C.boolean(bToi(checkUseDoubleclick())), C.boolean(bToi(wantUpdateCheck())), C.boolean(bToi(launchPoE()))) }
//export preConnect func preConnect(instance *C.freerdp) C.boolean { settings := instance.settings context := (*rdpContext)(unsafe.Pointer(instance.context)) settings.hostname = C.CString(*context.settings.hostname) settings.username = C.CString(*context.settings.username) settings.password = C.CString(*context.settings.password) settings.width = C.uint32(context.settings.width) settings.height = C.uint32(context.settings.height) settings.port = C.uint32(3389) settings.ignore_certificate = C.boolean(1) settings.performance_flags = (C.PERF_DISABLE_WALLPAPER | C.PERF_DISABLE_THEMING | C.PERF_DISABLE_MENUANIMATIONS | C.PERF_DISABLE_FULLWINDOWDRAG) settings.connection_type = C.CONNECTION_TYPE_BROADBAND_HIGH settings.rfx_codec = C.boolean(0) settings.fastpath_output = C.boolean(1) settings.color_depth = C.uint32(16) settings.frame_acknowledge = C.boolean(1) settings.large_pointer = C.boolean(1) settings.glyph_cache = C.boolean(0) settings.bitmap_cache = C.boolean(0) settings.offscreen_bitmap_cache = C.boolean(0) settings.order_support[C.NEG_DSTBLT_INDEX] = 0 settings.order_support[C.NEG_PATBLT_INDEX] = 1 settings.order_support[C.NEG_SCRBLT_INDEX] = 1 settings.order_support[C.NEG_MEMBLT_INDEX] = 0 settings.order_support[C.NEG_MEM3BLT_INDEX] = 0 settings.order_support[C.NEG_ATEXTOUT_INDEX] = 0 settings.order_support[C.NEG_AEXTTEXTOUT_INDEX] = 0 settings.order_support[C.NEG_DRAWNINEGRID_INDEX] = 0 settings.order_support[C.NEG_LINETO_INDEX] = 0 settings.order_support[C.NEG_MULTI_DRAWNINEGRID_INDEX] = 0 settings.order_support[C.NEG_OPAQUE_RECT_INDEX] = 1 settings.order_support[C.NEG_SAVEBITMAP_INDEX] = 0 settings.order_support[C.NEG_WTEXTOUT_INDEX] = 0 settings.order_support[C.NEG_MEMBLT_V2_INDEX] = 0 settings.order_support[C.NEG_MEM3BLT_V2_INDEX] = 0 settings.order_support[C.NEG_MULTIDSTBLT_INDEX] = 0 settings.order_support[C.NEG_MULTIPATBLT_INDEX] = 0 settings.order_support[C.NEG_MULTISCRBLT_INDEX] = 0 settings.order_support[C.NEG_MULTIOPAQUERECT_INDEX] = 1 settings.order_support[C.NEG_FAST_INDEX_INDEX] = 0 settings.order_support[C.NEG_POLYGON_SC_INDEX] = 0 settings.order_support[C.NEG_POLYGON_CB_INDEX] = 0 settings.order_support[C.NEG_POLYLINE_INDEX] = 0 settings.order_support[C.NEG_FAST_GLYPH_INDEX] = 0 settings.order_support[C.NEG_ELLIPSE_SC_INDEX] = 0 settings.order_support[C.NEG_ELLIPSE_CB_INDEX] = 0 settings.order_support[C.NEG_GLYPH_INDEX_INDEX] = 0 settings.order_support[C.NEG_GLYPH_WEXTTEXTOUT_INDEX] = 0 settings.order_support[C.NEG_GLYPH_WLONGTEXTOUT_INDEX] = 0 settings.order_support[C.NEG_GLYPH_WLONGEXTTEXTOUT_INDEX] = 0 context.clrconv = C.freerdp_clrconv_new(C.CLRCONV_ALPHA | C.CLRCONV_INVERT) return 1 }