mirror of
				https://github.com/LamGC/ContentGrabbingJi.git
				synced 2025-11-04 02:26:57 +00:00 
			
		
		
		
	[Add] PixivUgoiraBuilder 增加方法'buildUgoira(OutputStream, boolean)'以提供输出流给Builder输出已构建的动图数据;
[Add] PixivUgoiraBuilder 增加方法'getUgoiraMeta():JsonObject'方法, 可通过该方法获取动图元数据;
This commit is contained in:
		@ -82,7 +82,33 @@ public final class PixivUgoiraBuilder {
 | 
			
		||||
        log.debug("IllustId: {}, UgoiraMeta: {}", this.illustId, this.ugoiraMeta);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取动图元数据
 | 
			
		||||
     * @return 动图元数据, 返回的对象不影响Builder中的meta对象
 | 
			
		||||
     */
 | 
			
		||||
    public JsonObject getUgoiraMeta() {
 | 
			
		||||
        return this.ugoiraMeta.deepCopy();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 构建动图
 | 
			
		||||
     * @param original 是否为原图画质
 | 
			
		||||
     * @return 返回动图数据输入流
 | 
			
		||||
     * @throws IOException 当获取数据发生异常时抛出
 | 
			
		||||
     */
 | 
			
		||||
    public InputStream buildUgoira(boolean original) throws IOException {
 | 
			
		||||
        ByteArrayOutputStream bufferOutput = new ByteArrayOutputStream();
 | 
			
		||||
        buildUgoira(bufferOutput, original);
 | 
			
		||||
        return new ByteArrayInputStream(bufferOutput.toByteArray());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 构建动图
 | 
			
		||||
     * @param outputStream 动图输出流
 | 
			
		||||
     * @param original 是否为原图画质
 | 
			
		||||
     * @throws IOException 当获取数据发生异常时抛出
 | 
			
		||||
     */
 | 
			
		||||
    public void buildUgoira(OutputStream outputStream, boolean original) throws IOException {
 | 
			
		||||
        getUgoiraImageSize();
 | 
			
		||||
        log.debug("动图尺寸信息: Height: {}, Width: {}", height, width);
 | 
			
		||||
 | 
			
		||||
@ -95,7 +121,6 @@ public final class PixivUgoiraBuilder {
 | 
			
		||||
        HttpResponse response = httpClient.execute(request);
 | 
			
		||||
        log.trace("请求已发送, 正在处理响应...");
 | 
			
		||||
        ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(response.getEntity().getContent(), 64 * 1024));
 | 
			
		||||
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 | 
			
		||||
        ZipEntry entry;
 | 
			
		||||
        ByteArrayOutputStream cacheOutputStream = new ByteArrayOutputStream(512);
 | 
			
		||||
        HashMap<String, InputStream> frameMap = new HashMap<>(frames.size());
 | 
			
		||||
@ -140,7 +165,6 @@ public final class PixivUgoiraBuilder {
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        encoder.finishEncoding();
 | 
			
		||||
        return new ByteArrayInputStream(outputStream.toByteArray());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user