0

I am building a canvas game, and I draw images on canvas directly.

canvas.drawBitmap(bitmap, matrix, paint);

How can I use Fresco in order to load those bitmaps?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
  • what is costume view? – pskink Dec 18 '15 at 12:10
  • You clearly need to get access to `DraweeHierarchy.getTopLevelDrawable()` – EpicPandaForce Dec 18 '15 at 13:34
  • @EpicPandaForce but what if I just need the bitmap? – Ilya Gazman Dec 18 '15 at 13:45
  • their API returns Drawable. then use a Drawable, not Bitmap – pskink Dec 18 '15 at 13:50
  • You can try casting it to `BitmapDrawable`. Although I don't think you're managing their bitmaps properly then, as the `SimpleDraweeView` would. So you'll need to manage the closeable references yourself. Are you sure you don't want to use Glide (or maybe UIL although it stopped development 3 weeks ago) instead? – EpicPandaForce Dec 18 '15 at 13:53
  • and [the docs](http://frescolib.org/docs/writing-custom-views.html#_) show what to do when implementing custom views (you can just directly jump [here](http://frescolib.org/docs/writing-custom-views.html#your-custom-ondraw)) – pskink Dec 18 '15 at 19:42

1 Answers1

0

Your use case may best be met by using the image pipeline directly rather than use Drawees.

The hard part here is that you have to manage the memory yourself, rather than have Drawee do it for you. Follow the instructions on that page and the next two pages of docs ("DataSources" and "CloseableReferences").

tyronen
  • 2,558
  • 1
  • 11
  • 15
  • I solved this by using DraweeHolder. I manually call to mDraweeHolder.onDetach() and atach. And also to drawable.setBounds(...). I don't how ever use the toch event listener, nor the callbacks to mDraweeHolder.getTopLevelDrawable().setCallback(this). I also don't use verifyDrawable. For canvas I just use the tow things I mentioned at the top, and its look great. My only problem is the waiting time for images to load from local memory, but this for another topic... – Ilya Gazman Jan 04 '16 at 15:01