Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-10

Rotating a bitmap

12 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hi,

How can I rotate a bitmap 90? counterclockwise ?

Alternatively, how can I read/write the pixels in the bitmap ? I found ReadChannels/WriteChannels from RawImage, but they use a strange kind of position object which I don't understand :(

(an alternate answer is to implement rotated fonts in GTK1 ;))

Michael.

Graeme Geldenhuys
to Michael Van Canneyt

2008/10/27 Michael Van Canneyt :

Hi, How can I rotate a bitmap 90? counterclockwise ?

Wouldn't a rotation matrix do the trick? I remember the old fpGUI code (gfxbase.pas) unit used a 3x3 matrix to do translations and scalations calculations. I would imagine the same could be applied for rotation.

Wikipedia has some articles on rotation matrix, but the formulas look scary. ;-) Google revealed a lot of links on rotation matrix.

Alternatively, how can I read/write the pixels in the bitmap ?

The TFPCustomCanvas.Colors[] array?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Graeme Geldenhuys
to Michael Van Canneyt: How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the…

2008/10/27 Michael Van Canneyt :

Hi, How can I rotate a bitmap 90? counterclockwise ?

To save you the trouble... :-)

http://www.efg2.com/Lab/ImageProcessing/RotateScanline.htm http://www.delphi-central.com/tutorials/RotateBitmapBitBlt.aspx http://delphi.about.com/cs/adptips2001/a/bltip1201_4.htm

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Vincent Snijders
to Michael Van Canneyt: How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the…

2008/10/27 Michael Van Canneyt :

Show quoted text 17 lines
Hi, How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the pixels in the bitmap ? I found ReadChannels/WriteChannels from RawImage, but they use a strange kind of position object which I don't understand :( (an alternate answer is to implement rotated fonts in GTK1 ;)) Michael. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Vincent Snijders
to Michael Van Canneyt: How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the…

2008/10/27 Michael Van Canneyt :

Show quoted text 7 lines
Hi, How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the pixels in the bitmap ? I found ReadChannels/WriteChannels from RawImage, but they use a strange kind of position object which I don't understand :(

Maybe the lazintf example
(http://svn.freepascal.org/svn/lazarus/trunk/examples/lazintfimage/) can help. It rotates an image.

Vincent

Luiz Americo Pereira Camara
to Michael Van Canneyt: How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the…
Michael Van Canneyt wrote 10 lines
Hi, How can I rotate a bitmap 90? counterclockwise ? Alternatively, how can I read/write the pixels in the bitmap ? I found ReadChannels/WriteChannels from RawImage, but they use a strange kind of position object which I don't understand :( (an alternate answer is to implement rotated fonts in GTK1 ;))
Try
https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/gradcontrols/src/urotatebitmap.pas

Attached is a test example.

Luiz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RotateImage.zip
Type: application/zip
Size: 3723 bytes
Desc: not available
Url : http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081027/5897d6b9/attachment.zip

Michael Van Canneyt
to Graeme Geldenhuys: 2008/10/27 Michael Van Canneyt : To save you the trouble... :-)…
Graeme Geldenhuys wrote 11 lines
2008/10/27 Michael Van Canneyt : > Hi, > > How can I rotate a bitmap 90? counterclockwise ? To save you the trouble... :-) http://www.efg2.com/Lab/ImageProcessing/RotateScanline.htm http://www.delphi-central.com/tutorials/RotateBitmapBitBlt.aspx http://delphi.about.com/cs/adptips2001/a/bltip1201_4.htm

Thank you, but I already saw those prior to asking my questions. None of the techniques described there work in Lazarus.

Michael.

Michael Van Canneyt
to Vincent Snijders: 2008/10/27 Michael Van Canneyt : Maybe the lazintf example…
Vincent Snijders wrote 12 lines
2008/10/27 Michael Van Canneyt : > Hi, > > How can I rotate a bitmap 90? counterclockwise ? > > Alternatively, how can I read/write the pixels in the bitmap ? > I found ReadChannels/WriteChannels from RawImage, but they > use a strange kind of position object which I don't understand :( Maybe the lazintf example (http://svn.freepascal.org/svn/lazarus/trunk/examples/lazintfimage/) can help. It rotates an image.

Exactly what I needed. TLazIntfImage is the missing link :-)

Thanks to everyone for the links !

Michael.

Reenen Laurie
to Michael Van Canneyt

I had a similar problem... Eventually I moved on to GLscene...

Though obviously it's probably not at all what you want to do, but it's pretty easy to rotate things there. :-)

obj.rollangle := obj.rollangle + 90;

You can use an orthogonal camera if you don't want / need the perspective.

You can even let it "slowly" rotate using a cadencer, but let's not jump the gun here.

Regards,
-Reenen

2008/10/27 Michael Van Canneyt

Show quoted text 28 lines
On Mon, 27 Oct 2008, Vincent Snijders wrote: > 2008/10/27 Michael Van Canneyt : > > Hi, > > > > How can I rotate a bitmap 90? counterclockwise ? > > > > Alternatively, how can I read/write the pixels in the bitmap ? > > I found ReadChannels/WriteChannels from RawImage, but they > > use a strange kind of position object which I don't understand :( > > Maybe the lazintf example > (http://svn.freepascal.org/svn/lazarus/trunk/examples/lazintfimage/) > can help. It rotates an image. Exactly what I needed. TLazIntfImage is the missing link :-) Thanks to everyone for the links ! Michael. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081027/423b8248/attachment.html
Michael Van Canneyt
to Reenen Laurie
Reenen Laurie wrote 11 lines
I had a similar problem... Eventually I moved on to GLscene... Though obviously it's probably not at all what you want to do, but it's pretty easy to rotate things there. :-) obj.rollangle := obj.rollangle + 90; You can use an orthogonal camera if you don't want / need the perspective. You can even let it "slowly" rotate using a cadencer, but let's not jump the gun here.

All I need is to display a text at a 90? angle. Since GTK 1 doesn't support rotated text (hint hint), I draw the text on a bitmap, rotate that 90 degrees and display the bitmap, when I detect GTK1 as a widget set :-)

Requiring OpenGL for this would be slightly over the top, I'm sure you'll agree :-)

Michael.

Luiz Americo Pereira Camara
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
All I need is to display a text at a 90? angle. Since GTK 1 doesn't support rotated text (hint hint), I draw the text on a bitmap, rotate that 90 degrees and display the bitmap, when I detect GTK1 as a widget set :-)

Take a look at the unit i pointed. It has a class that does specifically this.

Luiz

Michael Van Canneyt
to Luiz Americo Pereira Camara
Luiz Americo Pereira Camara wrote 10 lines
Michael Van Canneyt escreveu: > All I need is to display a text at a 90? angle. Since GTK 1 doesn't > support rotated text (hint hint), I draw the text on a bitmap, rotate > that 90 degrees and display the bitmap, when I detect GTK1 as a widget > set :-) > Take a look at the unit i pointed. It has a class that does specifically this.

Indeed it does. Thanks for the hint.

I'll use my implementation since it uses the built-in rotated font if available. (and it was ready anyway :-) )

Michael.