* * *

Author Topic: TBitmap.ScanLine  (Read 15637 times)

tk

  • Jr. Member
  • **
  • Posts: 89
    • tkweb
TBitmap.ScanLine
« on: August 03, 2009, 11:28:13 am »
I began to port some components from Delphi to Lazarus but only for Windows mode. I really don't understand why TBitmap.ScanLine is not available in LCL. I am new to Lazarus but as I inspected the LCL Graphics unit there are still Windows only parameters like HBITMAP etc. used here so why not ScanLine? This is really a mess.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2460
Re: TBitmap.ScanLine
« Reply #1 on: August 03, 2009, 11:35:16 am »
A hbitmap is just a handle to a bitmap. There is nothing windows specific about that. Other widgetsets have sinilat references to the internal bitmap. That is why we still use a HBitmap for a TBitmap. If you googled a bit on lazarus+tbitmap+scanline you would have found the answer why a scanline isn't that trivial.
In short, on windows a scanline is a pointer to the raw pixels of a bitmap in graphics memory. Now imagine a crossplatform solution in Linux with a Xclient/server solution, where the images are stored on the server and the application is running on a client. How valid you think would a scanlinepointer be on a client ?
//--
{$I stdsig.inc}
//-Patches are always welcome at patch (at) dommelstein.net (please put the word "patch" in the subject)
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

tk

  • Jr. Member
  • **
  • Posts: 89
    • tkweb
Re: TBitmap.ScanLine
« Reply #2 on: August 03, 2009, 11:49:09 am »
I'm sorry TBitmap was always meant as an encapsulation of LOCALLY stored raster image (in Delphi) with the possibility to access bits directly like in Delphi. As this IMHO it should stay in Lazarus. Other approach is only making problems with porting Delphi apps to Lazarus. For remote pics LCL should have other components.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2652
    • My Lazarus wiki user page
Re: TBitmap.ScanLine
« Reply #3 on: August 05, 2009, 12:06:45 pm »
Oh, I always thought the main thing about a TBitmap was that it could be shown on a screen.

What you describe (a locally stored raster image) is more like the TFPImage.

tk

  • Jr. Member
  • **
  • Posts: 89
    • tkweb
Re: TBitmap.ScanLine
« Reply #4 on: August 05, 2009, 12:35:31 pm »
I solved this problem by writing a custom class (I needed a 32bpp bitmap for storing bitmaps with alpha channel usable both in Delphi and Lazarus & no 3rdparty). Anyway if my english is correct a bitmap is a map of bits or not? In Delphi TImage is used to display an image on the screen ;-)

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2652
    • My Lazarus wiki user page
Re: TBitmap.ScanLine
« Reply #5 on: August 05, 2009, 12:39:18 pm »
I see, you wrote a first party component.

circular

  • Hero Member
  • *****
  • Posts: 1462
    • Personal webpage
Re: TBitmap.ScanLine
« Reply #6 on: March 18, 2010, 05:01:40 pm »
I needed to access directly to some bitmap, so I wrote units for BGRA 8-bit bitmaps that can be drawn to the screen. To use it, you just modify the bitmap data with pointers (Scanline) or primitives and call InvalidateBitmap. Then you can draw it on some Canvas or merge it with another bitmap.

I have done Windows optimisation. It's really fast, like with Delphi. It should work with other operating systems, but I have not done the optimisation.

You can find the units here : http://sourceforge.net/projects/lazpaint/files/src/ (updated link)
It's called bgrabitmap.

To use it, you must add BGRABitmap and BGRABitmapTypes to "uses" clause.
« Last Edit: January 27, 2013, 04:17:30 pm by circular »
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 1462
    • Personal webpage
Re: TBitmap.ScanLine
« Reply #7 on: March 30, 2010, 12:11:35 pm »
In fact, it did not work on ubuntu, so I did a compatible version. Now it works on both Windows and Ubuntu (with gtk2).

I have added a page on lazarus wiki : http://wiki.freepascal.org/BGRABitmap/fr
Conscience is the debugger of the mind

cd

  • Jr. Member
  • **
  • Posts: 52
Re: TBitmap.ScanLine
« Reply #8 on: April 02, 2010, 10:39:06 am »
great thing!
it's sad that i can't use it because of the licensing.

circular

  • Hero Member
  • *****
  • Posts: 1462
    • Personal webpage
Re: TBitmap.ScanLine
« Reply #9 on: April 11, 2010, 07:54:04 pm »
Why ? It's free software.
Conscience is the debugger of the mind

Leledumbo

  • Hero Member
  • *****
  • Posts: 5244
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TBitmap.ScanLine
« Reply #10 on: April 12, 2010, 05:45:57 am »
I understand what cd means. You release the component with GPL license. That means it can't be used in closed source commercial softwares. Perhaps cd is making one.

cd

  • Jr. Member
  • **
  • Posts: 52
Re: TBitmap.ScanLine
« Reply #11 on: April 12, 2010, 07:23:22 am »
yes, Leledumbo is right.

circular

  • Hero Member
  • *****
  • Posts: 1462
    • Personal webpage
Re: TBitmap.ScanLine
« Reply #12 on: April 12, 2010, 09:40:46 am »
I understand. What license should I use instead to allow this while keeping it opensource ?
Conscience is the debugger of the mind

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2352
Re: TBitmap.ScanLine
« Reply #13 on: April 12, 2010, 11:57:15 am »
I understand. What license should I use instead to allow this while keeping it opensource ?

Best is LGPL+exception (FPC/LCL's license) and MPL dual licensed.

The first to remain FPC/Lazarus compatible, the second to remain compatible with  several Delphi open source teams (FPC/Lazarus sometimes cooperates with them)

Or simply BSD.

circular

  • Hero Member
  • *****
  • Posts: 1462
    • Personal webpage
Re: TBitmap.ScanLine
« Reply #14 on: April 12, 2010, 09:13:37 pm »
Hmm... so I have to choose between these two choices :
- LGPL+exception combined with MPL dual license
- BSD

Is that right ?

What must I write in the unit files to use theses licenses ?

If I use BSD, does that mean that I must write this :
Quote
* Copyright (c) 1998, Regents of the University of California
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of the University of California, Berkeley nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

It's weird because I am not related to the University of California. And I wonder if the following condition is not annoying if the library is included in a binary program :
Quote
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

What must I write to use "LGPL+exception combined with MPL dual license" ?
Conscience is the debugger of the mind

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads