[Gambas-user] Sample code to convert image to b/w image

Safiur Rahman isafiur at gmail.com
Mon Sep 18 19:13:01 CEST 2023


Thank you very much. This solved the problem.

On Mon, 18 Sep 2023, 22:03 Safiur Rahman, <isafiur at gmail.com> wrote:

> Hi
>
> Should I file a bug report in bugtracker?
>
> On Sun, Sep 17, 2023 at 7:47 AM Safiur Rahman <isafiur at gmail.com> wrote:
>
>> Application using gb.image, gb.image.effect and gb.media in addition to
>> gb.qt5
>>
>> There are two controls for image:
>> Drawing Area (dwgVideo) and ImageView (ImageView1)
>>
>> Private myPlayer As New MediaPlayer As "Player"
>>
>> Public Sub Button1_Click()
>>
>>   With myPlayer
>>     If .State = Media.Playing Then
>>       .Stop
>>     Endif
>>     .URL = "v4l2://" & ComboBox1.Text
>>     .SetWindow(dwgVideo)
>>     .Play()
>>   End With
>>
>> End
>>
>> 'While adding values of Opacity or threshold there is error
>> Public Sub BtnTakeShot_Click()
>>
>>   Dim ximage As Image
>>
>>   If myPlayer.State <> Media.Playing Then Return
>>   ximage = myPlayer.Video.Image
>>
>>   If chkopacity.Value Then
>>     ximage = ximage.Opacity(spnopacity.Value)
>>   Endif
>>
>>   If chkthres.Value Then
>>     ximage.Threshold(spnthreshold.Value)
>>   Endif
>>
>>   ImageView1.Image = ximage
>>
>> End
>>
>> Attached a sample project
>>
>> On Sun, Sep 17, 2023 at 1:19 AM Safiur Rahman <isafiur at gmail.com> wrote:
>>
>>> Hi
>>>
>>> I want to achieve the following black-in-white image output with
>>> Imagemagick with gambas
>>> $ convert old.png -alpha off -threshold 50% new.png
>>>
>>> Any sample code to achieve it?
>>>
>>> Also using Image.Opacity and Image.Threshold, I get following errors
>>>
>>> With Image.Opacity(50) I am getting error "The image must have an alpha
>>> channel"
>>> With Image.Threshold(0.5) the gambas crashed.
>>>
>>>
>>>
>>> --
>>> Regards
>>> Safiur Rahman
>>>
>>
>>
>> --
>> Regards
>> Safiur Rahman
>>
>
>
> --
> Regards
> Safiur Rahman
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230918/773a4190/attachment-0001.htm>


More information about the User mailing list