Este es parte del codigo, por cierto la applet java ya viene compilada este código lo saque decompilando el .jar con Java Decompiler
Código Java:
Ver original
int imageHeight = image.getHeight(null); int imageWidth = image.getHeight(null); int sliceHeight = 512; int sliceCount = imageHeight / sliceHeight; if (imageHeight % sliceHeight > 0) { sliceCount++; } int sliceNum = 0; int thisSliceHeight = sliceHeight; for (int sliceTop = 0; sliceTop < imageHeight; sliceTop += sliceHeight) { if (imageHeight - sliceTop < sliceHeight) { thisSliceHeight = imageHeight - sliceTop; } else { thisSliceHeight = sliceHeight; } sliceNum++; MorenaStudio.MainPanel.this.status.setText("Sending image to server..."); bufferedImage.createGraphics().drawImage(image, 0, 0 - sliceTop, null); tmp.deleteOnExit(); ImageIO.write(bufferedImage, "jpg", tmp); URL uploadURL; URL uploadURL; if (MorenaStudio.MainPanel.this.documentBase != null) { uploadURL = new URL(MorenaStudio.MainPanel.this.documentBase, "upload.php?slice_index=" + sliceNum + "&slice_total=" + sliceCount + "&uid=" + MorenaStudio.MainPanel.this.userId + "&auth=" + MorenaStudio.MainPanel.this.userAuth + "&twain_source=" + URLEncoder.encode(MorenaStudio.MainPanel.this.twainSourceName, "UTF-8")); } else { uploadURL = new URL("http://scanandupload.com/upload.php?slice_index=" + sliceNum + "&slice_total=" + sliceCount + "&uid=" + MorenaStudio.MainPanel.this.userId + "&auth=" + MorenaStudio.MainPanel.this.userAuth + "&twain_source=" + URLEncoder.encode(MorenaStudio.MainPanel.this.twainSourceName, "UTF-8")); } connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setUseCaches(false); connection.setDefaultUseCaches(false); connection.setRequestProperty("content-type", "img/jpeg"); connection.setRequestProperty("twain-source", MorenaStudio.MainPanel.this.twainSourceName); connection.setRequestProperty("slice-total", sliceCount); connection.setRequestProperty("slice-index", sliceNum); byte[] buffer = new byte[4096]; int bytes_read; while ((bytes_read = is.read(buffer)) != -1) { int bytes_read; out.write(buffer, 0, bytes_read); } out.close(); int c; while ((c = in.read()) != -1) { int c; } in.close(); finalImageServerPath = connection.getHeaderField("scan-img-path"); } if (!MorenaStudio.MainPanel.this.inAppletViewer) { if (MorenaStudio.MainPanel.this.appletContext != null) { MorenaStudio.MainPanel.this.appletContext.showDocument(nextURL); } else { } } MorenaStudio.MainPanel.this.status.setText("Scan is uploaded.")