小编Rez*_*eza的帖子

Webp 对 java 的支持

当我们基于网络的应用程序爱上 webp 图像格式时,我发现自己需要一种可以解码它的方法或库,

我已经编写了这段代码,但它只错过了本机解码器(我更喜欢它是一个 jar lib):

public BufferedImage decodeWebP(byte[] encoded, int w, int h) {
    int[] width = new int[]{w};
    int[] height = new int[]{h};

    byte[] decoded = decodeRGBAnative(encoded);  //here is the missing part , 
    if (decoded.length == 0) return null;

    int[] pixels = new int[decoded.length / 4];
    ByteBuffer.wrap(decoded).asIntBuffer().get(pixels);

    BufferedImage bufferedImage = new BufferedImage(width[0], height[0], BufferedImage.TYPE_INT_RGB);

    //  bufferedImage.setRGB(x, y, your_value);

    int BLOCK_SIZE = 3;

    for(int r=0; r< height[0]; r++) {
        for (int c = 0; c < width[0]; c++) { …
Run Code Online (Sandbox Code Playgroud)

java webp

13
推荐指数
1
解决办法
2万
查看次数

Vertx http 服务器线程已被阻塞 xxxx 毫秒,时间限制为 2000

我已经使用编写了一个大型http服务器,但是当并发请求数量增加时我收到此错误

 WARNING: Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 8458 ms, time limit is 1000
Run Code Online (Sandbox Code Playgroud)

io.vertx.core.VertxException:线程被阻止

这是我的完整代码:

  public class MyVertxServer {

public Vertx vertx = Vertx.vertx(new VertxOptions().setWorkerPoolSize(100));
private HttpServer server = vertx.createHttpServer();
private Router router = Router.router(vertx);

public void bind(int port){


    server.requestHandler(router::accept).listen(port);

}

public void createContext(String path,MyHttpHandler handler){

    if(!path.endsWith("/")){
        path += "/";
    }

    path+="*";


    router.route(path).handler(new Handler<RoutingContext>() {

        @Override
        public void handle(RoutingContext ctx) {

            String[] handlerID = ctx.request().uri().split(ctx.currentRoute().getPath());

            String suffix = handlerID.length > 1 ? handlerID[1] : null;
            handler.Handle(ctx, new VertxUtils(), suffix); …
Run Code Online (Sandbox Code Playgroud)

java multithreading http vert.x

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×2

http ×1

multithreading ×1

vert.x ×1

webp ×1