Forum > Beginners

Window and Bitmap

(1/4) > >>

Baggey:
Hi Everyone im new here,  ;)

Im thinking of given Lazarus a whirl. Ive been programming in BlitzMax for a few years now and want faster code.

Sorry if this question has already been asked.

Can anyone tell me how to open a simple window as a bitmap 800,600 and how to directly access the pixels using pointers. I want to write code with out all the windows Gadgets. If that's possible.

I want to make a quick and dirty TV static picture run as fast as possible altering every pixel randomly.

This would help me get started.  %)

Kind Regards Baggey

TRon:
Hi Baggey:
For something like that (no widgets, direct access to pixels) it is probably much easier/faster to use something like SDL. for more information on SDL see f.e. here.

jamie:
I didn't want to wade through the pile of stuff at that site, do you happen to know the min fpc compiler needed ?

KodeZwerg:
Put TImage on your form, make it client aligned.
Put in your Forms class a FBitmap: TBitmap variable.
Whenever needed, create a bitmap via FBitmap := TBitmap.Create and set size to whatever you need, when finished painting do a Image1.Picture.Bitmap.Assign(FBitmap) and not forget to free the FBitmap afterwards to avoid memory leaks.
You can at any time take that bitmap back from Image1, modify it and update Image1.

That is the most easiest way I guess.

For faster Pixel manipulation instead of pixel by pixel would be ScanLine for example.
Or use a 3rd party like BGRABitmap or Bitmap32.
For more speed you should get common to SDL or OpenGL.

TRon:

--- Quote from: jamie on February 18, 2024, 07:45:54 pm ---I didn't want to wade through the pile of stuff at that site, do you happen to know the min fpc compiler needed ?

--- End quote ---
Nothing to wade about  :)

Tutorial chapter 2 installation for Linux mentions the use of 3.0.4 but the windows version of that page even mentions 3.0.0 and 2.6.4. There is usually nothing special about SDL(2) headers.

@Baggey:
for a static tv picture it is faster not to manipulate individual pixels at runtime rather prepare 3 or 4 images (the quality of randomness gets better the more images you use) with random static and switch (quickly) between these pictures. That way you have room enough (time wise) to for example display a running bar at runtime.

Navigation

[0] Message Index

[#] Next page

Go to full version