当前位置: 首页>>代码示例>>Java>>正文


Java Capture类代码示例

本文整理汇总了Java中com.codename1.capture.Capture的典型用法代码示例。如果您正苦于以下问题:Java Capture类的具体用法?Java Capture怎么用?Java Capture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Capture类属于com.codename1.capture包,在下文中一共展示了Capture类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: captureRoundImage

import com.codename1.capture.Capture; //导入依赖的package包/类
private Image captureRoundImage() {
    try {
        int width = userPicture.getWidth();
        String result = Capture.capturePhoto(width, -1);
        if(result == null) {
            return userPicture;
        }
        Image capturedImage = Image.createImage(result);
        if(capturedImage.getHeight() != width) {
            if(capturedImage.getWidth() < capturedImage.getHeight()) {
                capturedImage = capturedImage.subImage(0, capturedImage.getHeight() / 2 - width / 2, width, width, false);
            } else {
                Image n = Image.createImage(width, width);
                n.getGraphics().drawImage(capturedImage, 0, width / 2- capturedImage.getHeight() / 2);
                capturedImage = n;
            }
        }
        return roundImage(capturedImage);
    } catch (IOException err) {
        err.printStackTrace();
        return userPicture;
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:DrSbaitso.java

示例2: createPictureCommand

import com.codename1.capture.Capture; //导入依赖的package包/类
private Command createPictureCommand(final Container grid) {
    return new Command("Take Picture") {
        public void actionPerformed(ActionEvent ev) {
            String picture = Capture.capturePhoto(1024, -1);
            if(picture == null) {
                return;
            }
            MultipartRequest mp = new MultipartRequest() {
                private long key;
                @Override
                protected void readResponse(InputStream input) throws IOException {
                    DataInputStream di = new DataInputStream(input);
                    key = di.readLong();
                }

                @Override
                protected void postResponse() {
                    final Button btn = createImageButton(key, grid, imageList.getSize());
                    imageList.addImageId(key);
                    grid.addComponent(0, btn);
                    if(!animating) {
                        animating = true;
                        grid.animateLayoutAndWait(400);
                        animating = false;
                    }
                }
            };
            mp.setUrl(UPLOAD_URL);
            try {
                mp.addData("i", picture, "image/jpeg");
                mp.addArgument("p", "Data;More data");
                NetworkManager.getInstance().addToQueue(mp);
            } catch(IOException err) {
                err.printStackTrace();
            }
        }
    };
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:39,代码来源:PhotoShare.java

示例3: onMain_CaptureButtonAction

import com.codename1.capture.Capture; //导入依赖的package包/类
@Override
protected void onMain_CaptureButtonAction(final Component c, ActionEvent event) {
    Capture.capturePhoto(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                if(evt == null){
                    return;
                }

                String path = (String) evt.getSource();
                if(ImageIO.getImageIO() != null) {
                    String photoName = "" + System.currentTimeMillis();
                    java.io.OutputStream os = Storage.getInstance().createOutputStream(photoName);
                    ImageIO.getImageIO().save(FileSystemStorage.getInstance().openInputStream(path), os, 
                            ImageIO.FORMAT_JPEG, imageWidth, imageHeight, 0.9f);
                    os.close();
                    Image img = Image.createImage(Storage.getInstance().createInputStream(photoName));
                    photo = photoName;
                    ((Label)c).setIcon(img);
                    c.getParent().getParent().animateLayout(400);
                }
            } catch (Exception ex) {
                Log.e(ex);
            }                        
        }
    });
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:28,代码来源:StateMachine.java


注:本文中的com.codename1.capture.Capture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。