Reputation: 115
Basicly my question is that how do I add a drawable resource to the R.java file in android eclipse so I can use it with this code:
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.kapschlogo);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
Image myImg = Image.getInstance(stream.toByteArray());
myImg.setAlignment(Image.MIDDLE);
doc.add(myImg);
The image is stored in the parent project folder but I cant figure out how do I add it tho te R file.
Upvotes: 1
Views: 14261
Reputation: 8747
Since the R.java file is automatically generated from your resources you need to put the image file(s) under the res/drawable folder and from there they will be indexed and accessible from R.drawable.myImageFile
(XML) or getResources().getDrawable(R.drawable.myImageFile);
(java)
Upvotes: 9