Convert to bitmap
JanTamis-zz opened this issue ยท 23 comments
Hello ik have a question, how can i convert the fastbitmap to a bitmap?
Got the same question
@JanTamis .. since you closed the Issue yourself, did you find a solution?
I did find a solution: in the source code there is this variable
private readonly Bitmap _bitmap;
if you chance this to
public readonly Bitmap _bitmap;
then you have a using bitmap
please note that you need to keep it readonly.
ah. ok. I fiddled around with my code and apparently one can just convert the FastBitmap by simply doing
Bitmap bitmap = myfastbitmap and vice versa.
i have tried that but it did not work.
do you use the nuget package?
yes i do
aah maybe there is a difference between the nuget package and the source code
i would be nice if the developer could tell us.
might be. If you want to I can send you my code.. maybe it could help you.
i would be nice
i dont know if it is smart to chance the variable to public
I mean.. it really depends on what you are doing.
i am creating a image processing class for my CCreative library and i need the bitmap so i can draw it in GDI+ and opengl
https://github.com/WaldemarLehner/EDEDSMVisualizer/blob/feature/gridlines/EDEDSMVisualizer/pages/Generation.xaml.cs#L379
The code is horrible, not commented.. but maybe it ill help you.
bitmap is a FastBitmap while _bitmap is a regular Bitmap
i think there is a difference to the nuget package and the source code
ps i copied the source code onto my project.
I mean.. in that case.. try the nuget package
i am trying to use as less as possible but maybe it is better. thank you for your comment.
you're welcome :) good luck!
lol i came to help you but you helped me. good luck to you to.
Heyo! Looks like I came a little late to the party, but anyways...
The reason I left _bitmap
private was to encourage using FastBitmap
as a thin layer that you'd use locally whenever you needed to manipulate a bitmap. Since FastBitmap works mostly by locking and unlocking the bitmap's memory region using LockBits
, it doesn't make sense to keep the bitmap locked further than a couple of operations, since to use the bitmap again to paint to the screen etc. you need the bitmap to be unlocked anyways, so creating and using FastBitmaps only within the methods that need them made more sense to me, and that allows _bitmap
to be hidden away.
If possible, I recommend passing the original Bitmap
around method parameters and lock/unlock FastBitmap
's locally, or wrap the Bitmap+FastBitmap pair on a structure and pass that instead.
Thank you for your response :)