java


Converting RGB byte array to BufferedImage


This is the code how I convert BufferedImage to byte array:
public void parseBufferedImage(BufferedImage image) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
Color color = new Color(image.getRGB(x, y), true);
outputStream.write(color.getRed());
outputStream.write(color.getGreen());
outputStream.write(color.getBlue());
outputStream.write(color.getAlpha());
}
}
image.flush();
byte[] data = outputStream.toByteArray();
}
I need to convert byte[] data back to an image, but I have only byte[] array so I do not know image size.
I want to save byte[] as a png, so I would be open to suggestions of another method.

Related Links

How can I tell a Linux Distro to apt-get install LibVLC if it doesn't have it from a running Java Program?
Sending Emails in java
OpenGl GLSL uniform set returns error
javafx.scene.media.MediaView cannot be cast to javafx.scene.Parent
Employee Weekly Hours
Why am i getting incompatible types error?
Undefined label in java android
If I have a class called 'exceptions' and it has only static classes, is this breaking Java standards?
Convert json map to java hashmap [duplicate]
Specific return type on AspectJ around call
Environment variables in Ubuntu Tomcat, Apache and Java
Array out of bound in Java
Why are we allowed to have a final main method in java?
Soap request with namespace
NamingException: jta.UserTransaction
BadParcelable Exception occasionally causing app to crash

Categories

HOME
wso2-am
gitlab
cloud
raspberry-pi
tesseract
bpmn
react-router
google-oauth
microservices
ezpublish
opengl-es-2.0
onelogin
django-imagekit
podio
upload
node-notifier
cross-validation
fancybox-3
google-cloud-ml
n-gram
moonmail
solaris-10
opencover
dcevm
wijmo
java-7
vlsi
spark-jobserver
bosh
google-qpx-express-api
framemaker
stringtemplate
asset-pipeline
mozilla
amazon-kinesis-kpl
mapdb
html5-fullscreen
main
simplexml
bitbucket-pipelines
qwerty
neuroscience
dynamics-crm-2013
ansible-playbook
dism
broadcastreceiver
janrain
google-closure
keydown
vao
convertapi
smartcontracts
prolog-setof
tropo
statsd
darcs
carrot
sqlbulkcopy
cudafy.net
linode
sonarlint-vs
android-textview
measures
google-web-starter-kit
player
firebaseui
moveit
prettytensor
ios8-today-widget
maven-tomcat-plugin
jms2
google-places
simple-framework
computer-algebra-systems
embedded-code
sortedlist
unity5.2.3
pretty-print
proj4js
kineticjs
formatjs
websocket4net
flask-cors
xojo
expected-exception
dealloc
c18
dbconnection
opcache
batterylevel
robotics-studio
free-variable
itmstransporter
gdata-api
jspinclude
bubble-chart
nsobject
pydot
data-loss
file-comparison
xfbml
remember-me
cxxtest
coda-slider
gamma
nsviewanimation
bespin
multi-tier
aquaticprime
scripting-languages
document-conversion

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