V
V
Vitaly Pukhov2015-04-28 02:27:11
Algorithms
Vitaly Pukhov, 2015-04-28 02:27:11

How to draw more efficiently in 2d in C#?

If in 2 words, you need to be able to draw an image on a bitmap, in an arbitrary place of an arbitrary size. I know about Graphics, but it is quite slow on large images, maybe there is something faster? Googling yielded nothing but DX, but there is no desire to mess around with float coordinates from 0 to 1.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Stanislav Silin, 2015-04-28
@Neuroware

If you want to be efficient, then OpenGL or DX will help you.
As far as I understand, you need the rendering element to be located on the form with the rest of the elements, so maybe SharpGL (used in such a bundle once for course work), I'm not sure about OpenTK so I didn't use it. I can’t say anything about DX, it didn’t work.

A
AxisPod, 2015-04-28
@AxisPod

Googling yielded nothing but DX, but there is no desire to mess around with float coordinates from 0 to 1.

It's all nonsense. Orthographic projection and work with screen coordinates in pixels.

M
Mrrl, 2015-04-28
@Mrl

How about Bitmap.LockBits()? It requires knowledge of the bitmap format, but is the fastest way to edit.

S
Stanislav Makarov, 2015-04-29
@Nipheris

If the already proposed options using OpenGL or D3D do not suit you (I will also advise you, because you will draw 1000 pictures with hardware acceleration in the same time that you draw through Graphics, which, being a wrapper around GDI +, draws everything on CPU), then try using the standard back buffer - drawing to it is noticeably faster than directly to the screen. If you have several such images, it is better to draw them to the buffer, and the buffer to the screen.
In general, to be serious: if you have animation and 2D sprites with real-time rendering - then spend time on OpenGL or Direct2D, if you have a purely computational load without interactivity - write the code for "drawing" one bitmap on another using pointers, or in general in C ++ with a call from a sharp (normal practice for computing tasks).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question