Java将图像像素保存为数组并绘制图像

我正在开发一个只下载jar的游戏,当你下载jar时,游戏将下载新的缓存。 同时我想展示一个漂亮的背景,没有加载链接,我想到了这个想法,我不确定它是否可能。 每个图像都被加载并逐个像素地绘制,是否可以获得图像,宽度,高度的所有像素颜色,然后打印值然后将它们放在一个数组中,例如: public int[] imagePixels = new int[]{PUT PIXELS HERE…}; 然后简单地使用一种方法来绘制背景? 这可能吗? 有没有更好的解决方案,如将图像打包到jar子里? 说明: 你有一个图像,我想加载该图像并加载每个像素,我们从第0行开始,按宽度和高度。 我想收集每个像素并将其保存到图像中,这样我就可以在不使用任何文件的情况下加载图像,只需从数组中提取像素。

Java事件传播已停止

我有一个主窗口: public class MainPanel extends JFrame implements MouseListener { public MainPanel() { setLayout(new FlowLayout()); setDefaultCloseOperation(EXIT_ON_CLOSE); addMouseListener(this); ChildPanel child = new ChildPanel(); add(child); JPanel spacer = new JPanel(); spacer.setPreferredSize(new Dimension(50, 50)); add(spacer); pack(); setLocationRelativeTo(null); } @Override public void mouseClicked(MouseEvent e) { System.out.println(“Mouse click event on MainPanel”); } } 和一个孩子JPanel: public class ChildPanel extends JPanel implements MouseListener […]

使用命令行JAVAC编译Java

我对使用cmd line javac进行编译有点新,我在编译这个简单的Base-Interface类时遇到了问题 package com.apress.prospring2.ch03.di; /** * @author janm */ public interface Encyclopedia { Long findLong(String entry); } package com.apress.prospring2.ch03.di; import java.util.Map; import java.util.HashMap; /** * @author janm */ public class HardcodedEncyclopedia implements Encyclopedia { private Map entryValues = new HashMap(); public HardcodedEncyclopedia() { this.entryValues.put(“AgeOfUniverse”, 13700000000L); this.entryValues.put(“ConstantOfLife”, 326190476L); } public Long findLong(String entry) { return […]

java中的OpenCV Mat对象序列化

我试图序列化对的映射并获得如下exception: java.io.NotSerializableException: org.opencv.core.Mat 有什么方法可以序列化吗?

如何将JLabel定位到Java GUI上的绝对位置

我在JPanel有很多JLabel (包括ImageIcon )。 而这个JPanel只是GUI上的一个面板; 还有很多其他面板。 我想将标签放在JPanel容器上的精确像素坐标上。 如果不使用GroupLayout ,我该怎么做?

为什么从main读取非静态变量有问题?

String name = “Marcus”; static String s_name = “Peter”; public static void main(String[] args) { System.out.println(name);//ERROR System.out.println(s_name);//OK } 错误:无法对非静态字段名称进行静态引用

为什么f:validateDoubleRange仅适用于@SessionScoped?

有人可以向我解释为什么我的例子中的Foo在到达validateDoubleRange类时总是为空? 最终结果是validation器的最小值始终为0.在outputText元素中,数字3在页面上显示正常。 如果我使用@SessionScoped而不是@ViewScoped来validation它是@ViewScoped 控制器: import java.io.Serializable; import java.math.BigDecimal; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; @ViewScoped @ManagedBean(name = “fooController”) public class FooController implements Serializable { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(FooController.class); private static final long serialVersionUID = 1L; private Foo foo; private BigDecimal amount; private Long fooId; public Long getFooId() { return fooId; } public void setFooId(Long […]

如何解决找不到媒体类型= multipart / form-data错误的MessageBodyWriter

如何为简单的多表单post配置提供程序。 任何建议/指针将不胜感激。 堆栈跟踪: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=multipart/form-data, type=class org.glassfish.jersey.media.multipart.FormDataMultiPart, genericType=class org.glassfish.jersey.media.multipart.FormDataMultiPart. at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149) at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1139) at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:433) at org.glassfish.jersey.test.inmemory.internal.InMemoryConnector.apply(InMemoryConnector.java:214) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:217) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655) pom.xml依赖项: org.glassfish.jersey.test-framework.providers jersey-test-framework-provider-inmemory 2.4 org.glassfish.jersey.media jersey-media-multipart 2.4 org.hamcrest hamcrest-all 1.3 代码: import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.client.Entity; […]

如何将JProfiler连接到在localhost上运行的应用程序?

我有一个在我的localhost上运行的应用程序,我想分析应用程序,看看如何增强应用程序的性能。 我正在按照定义执行设置步骤,但它无法连接到localhost服务器,是否有适当的分步指南可用于如何: 配置JProfiler以使用在localhost上运行的应用程序? 在分析应用程序时如何分析以及查找哪些区域? 使用Eclipse IDE配置JProfiler,现在能够在eclipse中查看运行下拉列表中的配置文件,但它们未被激活,那么如何激活它? 我有与此问题类似的问题,但我无法理解解决方案,对此的任何建议都将非常感激。 我现在尝试了一段时间没有成功配置JProfiler来处理在localhost上运行的应用程序,任何建议都将受到高度赞赏。 我是分析应用程序世界的新手,所以如果你能提供一些有用的指针,我将非常感激 我收到以下错误消息: Could not connect to 127.0.0.1:8849. Please make sure that the remote address is correct, the remote program is started properly, and the network route allows socket connections. 我已经使用新服务器集成设置了配置,不确定还需要做什么以及如何解决这个问题。 添加-agentpath:C:\Users\user~1.DOS\SOFTWA~1\JPROFI~1\bin\WINDOW~1\jprofilerti.dll=port=8849,nowait,id=117,config=C:\Users\user\.jprofiler6\config.xml到运行配置下的vm arguments ,然后当我运行配置时我得到 JProfiler> Protocol version 32 JProfiler> Using JVMTI JProfiler> JVMTI version 1.1 detected. JProfiler> 64-bit […]

我无法在Parse的应用程序中收到推送通知

我在我的应用程序中配置了Parse API,除推送通知外,一切正常。 我试图从网站发送它们,但他们没有到达应用程序。 我做了文档中写的所有内容 ,但我无法收到通知推送。 我能够收到一个,当我按下它应用程序崩溃。 现在我试图改变一些东西,但即使扭转我也不能再收到它们了。 我该如何解决我的问题? 编辑:由于一些用户可能感兴趣,这是我用于推送通知的代码的部分: 主类(不是MainActivity): public class InstantsApplication extends Application { public void onCreate() { super.onCreate(); // Hidden Parse.initialize(this, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”); ParseInstallation.getCurrentInstallation().saveInBackground(); ParsePush.subscribeInBackground(“”, new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Log.d(“com.parse.push”, “successfully subscribed to the broadcast channel.”); } else { Log.e(“com.parse.push”, “failed to […]