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

Define default locale and treat exceptions for Spring Locale Interceptor
overwrite a value inside a file in java
Open Source Continuous Integration tool for solo developer [Java] [closed]
Why is redis throwing NullPointerException running via JUnit with spring and default config?
Why does this python script run out of memory?
JPanel content not displaying
Regarding initialization of class instances
Sending events via code generation with annotations
Automatically generate Retrofit Types
ClassNotFoundException Error Spring + JSF trying to implement Spring Security login
JPA Entity updating database without persist/merge
Android Studio can't find installed SDK packages
Java SOAP client stub generation with service endpoint determined at runtime
Java EE Websocket: How to send keep sending data without receiving message?
Jetty 9.0.6 - java.net.ConnectException: Connection refused: connect
how to export Javassist CtClass to file

Categories

HOME
path-finding
spagobi
jsp-tags
cross-browser
blueprintjs
convolution
paradox
webrequest
windows-10-universal
etl
collectd
zend-framework3
circular-dependency
usergrid
commonmark
visual-studio-cordova
circuit
openrefine
highlight.js
pc
fatal-error
transformation
propel
scichart
clickonce
css-animations
accessor
format-specifiers
atlassian-crucible
windowbuilder
kendo-datasource
ecto
google-qpx-express-api
catch-all
avcapturesession
textmate
web-mining
libraries
az-application-insights
lumberjack
fedex
total-commander
eclipse-gef
long-polling
xml-documentation
scrollable
upstart
jedis
promela
hendrix
pillow
pdfclown
zendesk-app
query-performance
background-service
yt-project
removechild
lttng
markojs
nsviewcontroller
python-stackless
fadeout
srand
jmeter-maven-plugin
django-unittest
deis
unity3d-gui
p2
camanjs
codeigniter-url
codeigniter-routing
applescript-objc
id3v2
preferences
kgdb
android-2.2-froyo
transcoding
pyhdf
page-layout
mylyn
pushbackinputstream
sabredav
drools-planner
free-variable
selected
appconkit
online-compilation
uiviewanimation-curve
mercurial-server
gcj
servicehost
file-comparison
.nettiers
bespin
private-members
data-acquisition

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