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 pass parameter to data provider in testng from csv file
stanford tagger: error deleting last token
Eclipse development - change FieldEditor based on new value of other FieldEditor inside FieldEditorPreferencePage
Generate a random two-dimensional array of non-repeating numbers, Java
Server Socket implementation in J2ee server
When should classes be initialised - at load time or at first use?
How to add a view by context in Android
Email issue, sending some lines of string but not sending others
Android platform Bundle class experiencing internal array out of bounds exception
Error: Could not find or load main class JDK
“Reserved Error (-5001) and there is no reason for this error” during table creation in access database using java
Java i/o outputting a StringBuffer to a file
Could not initialize class org.openx.data.jsonserde.objectinspector.JsonObjectInspectorFactory
String comprasseed and expand [closed]
How I can specify a stylesheet into a fxml file?
How to break a loop in Java where the input size is not previously specified?

Categories

HOME
client
jdo
wso2
dictionary
xmpp
paw-app
win32gui
webpack-2
callback
onelogin
constraint-programming
uber-api
portia
slick-slider
awesome-wm
cloudkit
izpack
task
ibm-odm
zebra-printers
seaborn
pugjs
http-status-code-504
pythonanywhere
ab-testing
contextmenu
textfield
reverse-proxy
bootstrap-tour
crystal-reports-2010
h2db
apache-commons-io
contact-form
language-concepts
nssegmentedcontrol
hilbert-curve
mesos-chronos
preconditions
hp-ux
gulp-sourcemaps
estimote
websphere-mq-fte
qwt
promela
boost-multi-index
pebble-watch
tactic
lift-json
google-perftools
sybase-asa
hittest
pintos
word-vba-mac
xcb
nsviewcontroller
php-parse-error
freedesktop.org
srand
cakephp-3.1
graph-drawing
sailfish-os
oberon
heisenbug
aapt
jubula
resty-gwt
app42
flexmojos
ivyde
runtime.exec
odata4j
ftps
seed
quickdialog
dsn
newtonscript
parametric-equations
enter
nsdatecomponents
django-tagging
xdomainrequest
lang
blitz++
.nettiers
infrastructure
forums
eqatec
project-hosting
aquaticprime
sector
ubuntu-9.04

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App