java


Black image when drawing Image on Canvas


I am working on a game in which I am use Canvas to display my graphics. I haven't (and don't plan on) using any Swing components...
In my render method:
I am using a BufferStrategy that I get from the canvas.
BufferStrategy bs = this.getBufferStrategy();
if(bs == null){
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
Later in the same method I end up drawing images(entities, trees, map, etc.), disposing of g, and showing the reference 'bs'.
...drawings onto canvas(entities, trees, map, etc.)
//END RENDER
g.dispose();
bs.show();
In between when I //END RENDER and finish drawing to g I ask if the game is paused. If so I am create a BufferedImage from what was made by g. I render that BufferedImage and then render my inventory screen on top of that:
BufferedImage img = new BufferedImage(this.width, this.height, BufferedImage.TYPE_3BYTE_BGR);
Graphics gx = img.getGraphics();
game.paint(gx);
g.drawImage(img, 0, 0, Color.CYAN, this);
interfaceLayer.render(g);
I am getting a black BufferedImage in my reference img.
Am I doing something wrong by using a BufferStrategy? Should I not be using two different Graphics objects?
Here is a picture of what it looks like before and after I pause the game to get an idea.
Instead of:
g.drawImage(img, 0, 0, Color.CYAN, this);
I changed it to:
g.drawImage(img, 20, 20, Color.CYAN, this);
Just some arbitrary x,y so you can get the idea of whats going on with they layering.
Dont mind the gray box. It is a fillRect() that I will eventually be expanding as part of the graphics in my inventory screen.
Why the black image?

Related Links

How to get numbers of monitors
Struts Action property can't be accessed from external javaScript
Game Loop Is Not Destroying
How safe is upgrading java version for Cloudera?
Comparing objects of class which has implemented comparable
two arraylist merge with the same father class in JAVA
How to randomly read a pair from a Map until it is empty(Java)
Drawing Bitmap Along a Path on Canvas
Java game error, input == null?
How to run a .java program from another .java program?
enclosing all JSON Integer Values with double quotes “” using regular expressions
Java applet - MouseMotionListener works in eclipse but not on browser
JavaFX background colour not being set with CSS
jersey json trying to unmarshall to same object
Nutch + Solr - Indexer causes java.lang.OutOfMemoryError: Java heap space
Duplicate methods generated for a lambda with Eclipse compiler

Categories

HOME
xamarin
deezer
pycharm
google-api-php-client
fft
tesseract
infragistics
rubygems
binary-tree
alpha
amazon-cloudformation
awesome-wm
session-variables
kibana-4
tomcat6
ups
openrefine
jprofiler
predix
clickonce
jquery-ajaxq
orleans
microsoft-r
typo3-6.2.x
unboundid
r-raster
xquery-3.0
data-manipulation
oracle-fusion-middleware
kendo-ui-grid
framemaker
vsts-build-task
android-kernel
normal-distribution
catalog
nssegmentedcontrol
overlap
espeak
event-driven
document.write
bootstrapper
azure-ml
lumberjack
avro4s
reportingservices-2005
acoustics
logfiles
scrollable
strptime
diagnostics
media-player
flow-control
crosswalk-runtime
pintos
underscore.js-templating
mikroc
mathematica-frontend
simplewebrtc
qcustomplot
superstack
master-slave
make-install
php-internals
two-factor-authentication
energy
unity-networking
jmeter-maven-plugin
mutation-observers
splash
graph-drawing
skos
bridge.net
gui-test-framework
id3v2
document-classification
eol
xceed-datagrid
rtmfp
c18
dexterity
spring-io
yui-compressor
ember-app-kit
robotics-studio
free-variable
specification-pattern
isnullorempty
google-email-migration
removeclass
asyncfileupload
doh
javax.script
sef
exchange-server-2003
boost-smart-ptr
spec#
django-notification
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App