import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.PixelGrabber;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.media.Buffer;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Format;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.control.FrameGrabbingControl;
import javax.media.format.RGBFormat;
import javax.media.format.VideoFormat;
import javax.media.protocol.DataSource;
import javax.media.protocol.PushBufferDataSource;
import javax.media.util.BufferToImage;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import jmapps.jmstudio.CaptureDialog;
import jmapps.ui.PlayerFrame;
import jmapps.util.CDSWrapper;
import jmapps.util.JMFUtils;
public class JMFDemo extends PlayerFrame {
public JMFDemo() {
super(null, "��Ƶ����");
}
DataSource dataSource;
private CaptureDeviceInfo infor;
private MediaLocator mediaLocator;
String str1 = "vfw:Logitech USB Video Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
private String url = "vfw:Microsoft WDM Image Capture (Win32):0";
private Component com;
private JPanel panel;
private int captureCount = 0;
FrameGrabbingControl controlGrabber;
public void play() {
if (mediaPlayerCurrent.getState() != mediaPlayerCurrent.Started) {
mediaPlayerCurrent.start();
}
}
private void init() throws NoPlayerException, IOException {
// setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
String nameCaptureDeviceAudio = null;
String nameCaptureDeviceVideo = null;
CaptureDialog dialogCapture = new CaptureDialog(this, null);
dialogCapture.show();
if (dialogCapture.getAction() == CaptureDialog.ACTION_CANCEL)
return;
CaptureDeviceInfo cdi = dialogCapture.getAudioDevice();
if (cdi != null && dialogCapture.isAudioDeviceUsed())
nameCaptureDeviceAudio = cdi.getName();
cdi = dialogCapture.getVideoDevice();
if (cdi != null && dialogCapture.isVideoDeviceUsed())
nameCaptureDeviceVideo = cdi.getName();
dataSource = JMFUtils.createCaptureDataSource(nameCaptureDeviceAudio,
dialogCapture.getAudioFormat(), nameCaptureDeviceVideo,
dialogCapture.getVideoFormat());
DataSource cdswrapper = new CDSWrapper(
(PushBufferDataSource) dataSource);
dataSource = cdswrapper;
dataSource.connect();
open(dataSource);
JPanel controlPanel = new JPanel();
controlPanel.setName("controlPnael is here");
add(BorderLayout.SOUTH, controlPanel);
JButton capture = new JButton("Capture Image");
capture.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
mediaPlayerCurrent.stop();
Buffer bufferFrame;
BufferToImage bufferToImage;
Image image;
BufferedImage bi;
controlGrabber = (FrameGrabbingControl) mediaPlayerCurrent
.getControl("javax.media.control.FrameGrabbingControl");
bufferFrame = controlGrabber.grabFrame();
bufferToImage = new BufferToImage((VideoFormat) bufferFrame
.getFormat());
image = bufferToImage.createImage(bufferFrame);
File out = new File("capture" + (++captureCount) + ".png");
try {
bi = toBufferedImage(image);
ImageIO.write(bi, "png", out);
} catch (IOException e1) {
e1.printStackTrace();
}
mediaPlayerCurrent.start();
}
});
controlPanel.add(BorderLayout.CENTER, capture);
JButton playStop = new JButton("stop");
// add(BorderLayout.SOUTH,playControl);
playStop.addActionListener(new ActionListener() {
// @Override
public void actionPerformed(ActionEvent arg0) {
mediaPlayerCurrent.stop();
}
});
controlPanel.add(BorderLayout.EAST, playStop);
JButton playStart = new JButton("start");
// add(BorderLayout.SOUTH,playControl);
playStart.addActionListener(new ActionListener() {
// @Override
public void actionPerformed(ActionEvent arg0) {
// mediaPlayerCurrent.stop();
if (mediaPlayerCurrent.getState() != mediaPlayerCurrent.Started) {
mediaPlayerCurrent.start();
}
}
});
controlPanel.add(BorderLayout.WEST, playStart);
addWindowListener(new WindowAdapter() {
// @Override
public void windowClosing(WindowEvent e) {
mediaPlayerCurrent.close();
dataSource.disconnect();
System.out.println("exit.....");
System.exit(0);
}
});
}
public static boolean hasAlpha(Image image) {
// If buffered image, the color model is readily available
if (image instanceof BufferedImage) {
BufferedImage bimage = (BufferedImage) image;
return bimage.getColorModel().hasAlpha();
}
// Use a pixel grabber to retrieve the image's color model;
// grabbing a single pixel is usually sufficient
PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
try {
pg.grabPixels();
} catch (InterruptedException e) {
}
// Get the image's color model
ColorModel cm = pg.getColorModel();
return cm.hasAlpha();
}
public static BufferedImage toBufferedImage(Image image) {
if (image instanceof BufferedImage) {
return (BufferedImage) image;
}
// This code ensures that all the pixels in the image are loaded
image = new ImageIcon(image).getImage();
// Determine if the image has transparent pixels; for this method's
// implementation, see e661 Determining If an Image Has Transparent
// Pixels
boolean hasAlpha = hasAlpha(image);
// Create a buffered image with a format that's compatible with the
// screen
BufferedImage bimage = null;
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
try {
// Determine the type of transparency of the new buffered image
int transparency = Transparency.OPAQUE;
if (hasAlpha) {
transparency = Transparency.BITMASK;
}
// Create the buffered image
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
bimage = gc.createCompatibleImage(image.getWidth(null), image
.getHeight(null), transparency);
} catch (HeadlessException e) {
// The system does not have a screen
System.err.println("The system does not have a screen!");
System.exit(-1);
}
if (bimage == null) {
// Create a buffered image using the default color model
int type = BufferedImage.TYPE_INT_RGB;
if (hasAlpha) {
type = BufferedImage.TYPE_INT_ARGB;
}
bimage = new BufferedImage(image.getWidth(null), image
.getHeight(null), type);
}
// Copy image to buffered image
Graphics g = bimage.createGraphics();
// Paint the image onto the buffered image
g.drawImage(image, 0, 0, null);
g.dispose();
return bimage;
}
private MediaLocator autoDetect() {// �Զ�ʶ���ܺ���
MediaLocator ml = null; // ��Ƶ�ɼ��豸��Ӧ��MediaLocator
VideoFormat currentFormat = null;// �û����ƻ����Ƶ�ɼ��豸֧�ֵĸ�ʽ
Format setFormat = null;// �û�������Ƶ�ɼ��豸����ĸ�ʽ
Format[] videoFormats = null;// ��Ƶ�ɼ��豸֧�ֵ����и�ʽ
System.out.println(" AutoDetect for VFW");// VFW:��� Video for Windows
// ��õ�ǰ�����豸�б�
Vector deviceList = CaptureDeviceManager.getDeviceList(null);
Captu
springmvc+mybatis+freemarker



Spring MVC、MyBatis 和 FreeMarker 是三个在Java Web开发中广泛应用的技术框架,它们共同构建了一个高效、灵活的Web应用程序架构。在这个项目中,`springmvc+mybatis+freemarker` 的组合提供了模型-视图-控制器(MVC)的设计模式,数据持久层的处理以及模板引擎的功能。 Spring MVC 是 Spring 框架的一部分,它为Web应用提供了一个分层架构。Spring MVC负责处理HTTP请求,通过DispatcherServlet分发到相应的控制器(Controller),控制器处理业务逻辑后,将模型(Model)数据传递给视图(View)。Spring MVC还支持依赖注入,使得组件之间松耦合,便于测试和维护。 MyBatis 是一个轻量级的持久层框架,它允许开发者将SQL语句直接写在XML配置文件或者Mapper接口中,与Spring整合后,可以实现事务管理和服务层的解耦。MyBatis通过SqlSession对象执行SQL,返回结果集,然后映射成Java对象,减少了手动操作JDBC的繁琐。 FreeMarker 是一个强大的模板引擎,用于生成动态HTML或其他格式的输出。在Spring MVC中,FreeMarker作为视图解析器,接收模型数据,并根据预先定义的模板文件生成最终的响应。开发者可以在FreeMarker模板中使用简单的语法来引用模型数据,实现灵活的页面布局和样式。 在这个项目中,"断点下载"标签可能表示该工程包含了处理大文件下载时支持续传的功能。这通常需要服务器端保存已下载的部分信息,客户端通过某种方式(如HTTP头的Range字段)告知服务器从哪里继续下载,从而实现断点续传,提高用户体验。 SpringCloudFrame 文件可能代表这是一个基于Spring Cloud的微服务框架项目。Spring Cloud 提供了一套微服务解决方案,包括服务发现、配置中心、负载均衡、熔断机制等,使得构建分布式系统更加容易。Spring Cloud与Spring MVC和MyBatis结合,可以帮助开发者构建大规模的云原生应用。 这个项目涵盖了Web开发中的核心组件,包括前端展示、后端控制和数据访问,同时考虑到了大文件下载的优化和微服务的实现。这样的项目实例对于学习和理解Java Web开发流程、实践MVC模式、掌握MyBatis操作数据库以及利用Spring Cloud构建分布式系统都有极大的帮助。开发者可以通过阅读源代码、调试和修改,加深对这些技术的理解和运用。




















































































































- 1
- 2

- 粉丝: 206
- 资源: 2
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- Proteus 仿真MSP430实例之10 ADC12.zip
- Proteus 仿真MSP430实例之09 SPI.zip
- 基于两电平逆变器的SVPWM调制技术及空间矢量优化在Simulink仿真模型与Visio原理图中的实践与应用研究 ,基于两电平逆变器的SVPWM调制算法研究 - 文件包含Simulink仿真模型与Vi
- 洛谷P2089代码题解
- 基于事件触发机制的多智能体系统跟踪共识与共识策略研究,基于事件触发机制的多智能体系统跟踪共识研究:非理想一般线性系统的共识策略与算法设计,基于观测器的非理想一般线性多智能体系统的事件触发跟踪共识 关键
- MATLAB仿真:基于人工势场法的无人车路径规划算法Demo,含目标定位与障碍物避障,详细代码注释助力初学者快速掌握 ,MATLAB中基于人工势场法的无人车路径规划算法Demo:目标定位与障碍物规避的
- 三相并网仿真系统中的准PR控制策略及电容电流反馈技术应用研究,三相并网仿真技术:准PR控制与电容电流反馈策略的探讨与实践,三相并网仿真,准PR控制+电容电流反馈 ,三相并网仿真; 准PR控制; 电容电
- 基于改进麻雀算法的径向基神经网络优化与回归预测建模:Excel数据驱动的误差评估与可视化,基于改进麻雀算法的径向基神经网络优化与回归预测建模:Excel数据驱动的误差评估与可视化分析,改进麻雀算法优化
- 正齿轮减速机 - 变速箱 正齿轮减速器变速箱 3D 在 Creo 11 中设计 包括 STEP 组件
- 基于虚拟惯性控制与下垂控制的双馈风力发电机多机多节点一次调频模型:高风电渗透率下的储能与光伏系统整合仿真研究,基于虚拟惯性控制与下垂控制的双馈风力发电机多机多节点一次调频模型:仿真与接入混合能源系统研
- 基于ECMS的并联混合动力汽车能量管理策略研究:实现最小等效燃油消耗与多工况仿真分析,基于ECMS能量管理策略的并联混合动力汽车仿真研究:实现等效燃油消耗最小化与性能优化,ECMS,等效燃油消耗最小策
- 基于Matlab Simulink的双馈风机并网仿真模型:高效稳定、自调节与测频功能实现,基于Matlab Simulink的双馈风机并网模型:可测频自调波形稳定,仿真速度快捷高效,风机并网matla
- 标题:基于GWO-LSSVM灰狼算法优化最小二乘支持向量机回归预测的易用型软件工具-适应度函数优化参数与结果存储升级版 注:标题字数控制在40字以上,90字以内,根据您提供的文字提炼得出,力求简洁
- 分布式驱动电动汽车路面附着系数精确估计技术研究:基于无迹卡尔曼滤波(UKF)与容积卡尔曼滤波(CKF)的S-function估计算法及其在不同工况下的应用评估 ,基于分布式驱动电动汽车的动态路面附着系
- 基于蛇优化器(Snake Optimizer, SO)的无人机路径规划技术:探索算法在科学和工程应用中的高效性能与改进空间,**基于自然启发的蛇优化器在无人机路径规划的高效应用:提升算法质量与现实实践
- MDK5.41(含科学使用文件)



- 1
- 2
前往页