android


Saving canvas draw in bitmap showing white screen


I am trying to save canvas draw into bitmap using this code:
#Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
myBitmap=Bitmap.createBitmap((int)this.getWidth(), (int)this.getHeight(), Config.ARGB_8888);// bitmap created
canvas=new Canvas(myBitmap);
canvas.drawPath(path, paint);
}
For paint code :
public TouchEventView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(5);
}
According to the concept it should draw lines on touching screen but when I run the app code only white screen shows and I am not able to draw anything!
Note:
The app runs correctly if I remove:
myBitmap=Bitmap.createBitmap((int)this.getWidth(), (int)this.getHeight(), Config.ARGB_8888);// bitmap created
canvas=new Canvas(myBitmap);
But I want to save my canvas in a bitmap for future processing .
How to save canvas in bitmap correctly ? What changes should I bring ?

Related Links

EditText goes to another child on ExpandableListView
Closing the app drawer in Android Wear 2.0
About java.lang.UnsatisfiedLinkError´╝Üorg.bytedeco.javacpp.avutil
Using javacpp + openblas in Android
Check if camera is busy with another apps
Android BLE Reading characrteristics
Alarm is called on Samsung Galaxy Tab 3, But not called on LeEco Le2
How to get network type in dual sim in android
Not able to make mergDatagridScroller running
StopService not being called in Android Application
limitToFirst in Firebase Query Reference not working on Android
Integrate tesseract with cocos2d-x framework
About onDraw method
How to set permission to device gallery?
How to manage cookies between different activities, using Volley?
How to create Android toolbar show like airbnb app

Categories

HOME
batch-file
checkstyle
nunit
depth
pyqt
rsa
mysql-workbench
camera
solaris
emscripten
nested-if
interpolation
nuget-package
jax-ws
frontend
mod-security
why3
ycsb
selectize.js
azure-iot-hub
google-content-api
mapstruct
breadth-first-search
dataflow-diagram
ios10.2
exit
pchart
qliksense
beta
stackexchange
delimiter
mat
outliers
apktool
inversion-of-control
tizen-tv
winpe
realm-mobile-platform
twiml
recurring-events
scatter3d
kodi
autolisp
spring-security4
clickjacking
jett
hreflang
protege4
lint
imagenet
apriori
escpos
dbnull
rfc3339
libgphoto2
sundials
payload
monkey
d3-force-directed
pybrain
objectscript
testrail
actor-platform
adafruit
tooleap
xdoclet
appscale
cassia
omniauth-facebook
deep
nss
cda
yajsw
beanstalk
kendo-upload
concurrentmodification
assertion
xvim
evolus-pencil
vacuum
skspritenode
canvg
actionfilterattribute
boost-program-options
viewer
primitive-types
structuremap3
metatrader5
wcm
create.js
codeplex
memset
extjs2
drupal-nodes
away3d
mbunit
gpars
device-width
tree-balancing
onmousemove
cakephp-1.2
floating-point-exceptions
screen-size
jquery-tools
workflow-services
tmx
presentation-layer
instantiationexception
jqueryform
rowlex
openfaces
perl5.12
fdf
pnrp

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