Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Trouble with ui_bitmap_draw

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trouble with ui_bitmap_draw

    Anyone see any problem with this code? It's taken pretty much from the help file...

    dim jpg as B
    dim bmp as B
    Dim Global fname as c

    fname = varShowImagePath + varShowImageName
    If Isnull(fname) = .f. then
    jpg = file.to_blob(fname)

    bmp = jpeg_to_bitmap(jpg)

    pixsize = ui_bitmap_info_get(bmp, "w,h")
    xpix = val(word(pixsize, 1, ","))
    ypix = val(word(pixsize, 2, ","))
    xperin = ui_info(4)
    yperin = ui_info(5)
    width = xpix/xperin
    height = ypix/yperin
    ui_bitmap_create("combine", width, height)
    ui_bitmap_load("image_name", bmp)
    ui_bitmap_draw("combine", <<%code%
    bitmap("image_name", 0, 0,0,0,"ROTATE-RIGHT")
    %code%)

    This is the error I'm getting on the ui_bitmap_draw line...

    Script:OnInit line:28
    ui_bitmap_draw("combine", <<%code%
    ui_bitmap_draw: bitmap 'combine' not found

    but I'm creating a couple of lines above. If you do a search in help on ui_bitmap_draw this is the code they use. Thanks... driving me crazy!

    #2
    Re: Trouble with ui_bitmap_draw

    Originally posted by Davidk View Post
    ... driving me crazy!
    It drives me crazy too! Unfortunately, both the explanations and the examples in the help file regarding A5 graphics is sadly deficient. The examples are overly complex and tend to combine multiple techniques making it very difficult to do something simple. You can indeed spend hours spinning your wheels studying the code examples. Anyway, the following works but might require further tweaking. I have assumed that you are trying to display a jpg image.

    Code:
    filename = "C:\Graphic Images\Autumn 008.jpg"
    
    width = 8
    height = 4
    
    imagebits = file.to_blob(filename)
    bmpbits = jpeg_to_bitmap(imagebits)
    
    ui_bitmap_load("selected_picture", bmpbits)
    ui_bitmap_create("thumbnail", width, height)
    
    ui_bitmap_draw("thumbnail",<<%code%
    bitmap("selected_picture",0,0,width,height)
    %code%)
    
    ui_dlg_box("Display Bitmap", <<%dlg%
    {image=thumbnail}
    %dlg%)
    
    ui_bitmap_drop("thumbnail")
    end
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com


    Comment


      #3
      Re: Trouble with ui_bitmap_draw

      Works just fine for me.

      It's driving you crazy because this code, which I don't know where you got it from, is definitely NOT complete.

      Your code stops dead in it's track most likely at:
      fname = varShowImagePath + varShowImageName
      You have to dim these 2 variables first: varShowImagePath and varShowImageName
      Actually, it does not stop there but it does not produce any image because it does not load any file.

      Second, your code is missing "end if".

      For testing purpose, just hard-code it with the actual file name.

      Comment


        #4
        Re: Trouble with ui_bitmap_draw

        Originally posted by G Gabriel View Post
        Works just fine for me.
        ...
        For testing purpose, just hard-code it with the actual file name.
        Doesn't work for me, Gabe. Here is my code:
        Code:
        im jpg as B
        dim bmp as B
        Dim Global fname as c
        
        fname = "C:\Graphic Images\For a few dollars more.jpg"
        
        IF Isnull(fname) = .f. THEN
            jpg = file.to_blob(fname)
        END IF
        
        bmp = jpeg_to_bitmap(jpg)
        
        pixsize = ui_bitmap_info_get(bmp, "w,h")
        xpix = val(word(pixsize, 1, ","))
        ypix = val(word(pixsize, 2, ","))
        xperin = ui_info(4)
        yperin = ui_info(5)
        width = xpix/xperin
        height = ypix/yperin
        ui_bitmap_create("combine", width, height)
        ui_bitmap_load("image_name", bmp)
        ui_bitmap_draw("combine", <<%code%
        bitmap("image_name", 0, 0,0,0,"ROTATE-RIGHT")
        %code%)
        Peter
        AlphaBase Solutions, LLC

        [email protected]
        https://www.alphabasesolutions.com


        Comment


          #5
          Re: Trouble with ui_bitmap_draw

          Peter,

          Are you saying the code following "here is my code:" does not work? If so, it does work (after adding a "d" to your "im" on line 1). But for it to show the result you have to add the following line at the end.

          Code:
          ui_dlg_box("","{image=combine}")
          You can see that it works by changing the rotate statement from right to left of just "".

          Raymond Lyons

          Comment


            #6
            Re: Trouble with ui_bitmap_draw

            Of course it won't work for you Peter.You put end if at the wrong spot. It should be all the way at the end of the script and if you are going to hard-code the file name, you don't need the IF statment to begin with.

            Comment


              #7
              Re: Trouble with ui_bitmap_draw

              Originally posted by G Gabriel View Post
              Of course it won't work for you Peter.You put end if at the wrong spot. It should be all the way at the end of the script and if you are going to hard-code the file name, you don't need the IF statment to begin with.
              If when hard coding you don't need the IF statement to begin with, it can't really matter where you put the end if (in any case, that is not the problem). And, as I previously stated, Peter's code does work, he just needed the ui_dlg_box("","{image=combine}") line to see some results. Peter's code with my jpg file and the added line to show the result:

              Code:
              dim jpg as B
              dim bmp as B
              Dim Global fname as c
              dim combine as c
              
              fname = "C:\0_pca_out\email_reader.jpg"
              
              IF Isnull(fname) = .f. THEN
                  jpg = file.to_blob(fname)
              END IF
              
              bmp = jpeg_to_bitmap(jpg)
              
              pixsize = ui_bitmap_info_get(bmp, "w,h")
              xpix = val(word(pixsize, 1, ","))
              ypix = val(word(pixsize, 2, ","))
              xperin = ui_info(4)
              yperin = ui_info(5)
              width = xpix/xperin
              height = ypix/yperin
              ui_bitmap_create("combine", width, height)
              ui_bitmap_load("image_name", bmp)
              ui_bitmap_draw("combine", <<%code%
              bitmap("image_name", 0, 0,0,0,"rotate-right")
              %code%)
              ui_dlg_box("","{image=combine}")

              Comment


                #8
                Re: Trouble with ui_bitmap_draw

                Here's the full code... I just included those bit which were pertinent to see if anyone could see a problem with the syntax... sorry.

                There is a problem... but not one that is obvious... because of all the great responses I knew something was wrong... but not in my code.

                Here's the full code...

                'On Error Goto Proc_Err

                dim jpg as B
                dim bmp as B
                Dim Global fname as c

                'the following two variables are dimensioned globally

                fname = varShowImagePath + varShowImageName
                If Isnull(fname) = .f. then
                jpg = file.to_blob(fname)
                bmp = jpeg_to_bitmap(jpg)
                pixsize = ui_bitmap_info_get(bmp, "w,h,b")
                xpix = val(word(pixsize, 1, ","))
                ypix = val(word(pixsize, 2, ","))
                bpix = val(word(pixsize, 3, ","))
                xperin = ui_info(4)
                yperin = ui_info(5)
                width = xpix/xperin
                height = ypix/yperin

                ui_bitmap_create("combine", width, height)
                ui_bitmap_load("image_name", bmp)
                ui_bitmap_draw("combine", <<%code%
                bitmap("image_name", 0, 0, width, height,"BEST-FIT, ROTATE-RIGHT")
                %code%)

                x = OLE.createpicture("combine")
                :frmShowImage:activex1.activex.Picture = x
                :frmShowImage:imagefilename.text = fname

                ui_bitmap_drop("combine")
                End if

                Proc_Exit:
                end

                Proc_Err:
                err = error_code_get()
                msg = error_text_get(err)
                ui_msg_box("Digital Adjuster", "Error # : " + err + " : " + msg)
                resume Proc_Exit


                So, the problem shows up when you throw my JPG image at it. Peter's JPG was fine... if you display the pixels for Peters image they'll be "reasonable"... whatever that is. For my image... even though it's small - 621k - it's pixel dimensions are 2304 x 1728. Divide those by the bits per pixel (96) and you get an image being created of 24 x 18. ui_bitpmap_create can't handle this so no image gets created so ui_bitmap_draw blows up. I need to test the create to make sure it's there first. An image size of 20x15 works... who knows.

                Anyway... even at 20x15 the image that displays is really bad because of the colour depth I suppose.

                All I want to do is rotate an image and display it in my Activex control... so hard to do... yikes.

                This is not easy stuff to figure out... thank you for the discussion... never would have found it otherwise.

                Comment


                  #9
                  Re: Trouble with ui_bitmap_draw

                  David:
                  I don't know what to make of:
                  varShowImagePath + varShowImageName
                  With these 2 variables you get the file name. I am guessing there is a previous code that presents an xdlg to choose the image file and then the path is assigned to these variables and thus the code is still incomplete in explaining these 2 variables.

                  As to the image size, you could manipulate it any way you want. You could further divide the dimension by any factor to get it small enough. No, ui_bitmap_draw does not blow up. The image is there in cache memory and to see it you have to place it somewhere as for example in an xdlg.
                  Last edited by G Gabriel; March 22, 2009, 08:08 AM.

                  Comment


                    #10
                    Re: Trouble with ui_bitmap_draw

                    Disregard. It seems that you already figured it out.
                    Last edited by G Gabriel; March 22, 2009, 08:12 AM.

                    Comment


                      #11
                      Re: Trouble with ui_bitmap_draw

                      Originally posted by Raymond Lyons View Post
                      Peter,

                      Are you saying the code following "here is my code:" does not work? If so, it does work (after adding a "d" to your "im" on line 1). But for it to show the result you have to add the following line at the end.

                      Code:
                      ui_dlg_box("","{image=combine}")
                      You can see that it works by changing the rotate statement from right to left of just "".

                      Raymond Lyons
                      Ray,

                      I lost the "d" in the cut & paste. Yeah, the ui_dlg - like, duhhhhh. Thanks for pointing that out. I was so fixated on one thing that I missed the obvious.

                      ---
                      P.S. Of course, I didn't mean it's "my" code. Just that "the" code wouldn't work w/o the dlg.
                      Peter
                      AlphaBase Solutions, LLC

                      [email protected]
                      https://www.alphabasesolutions.com


                      Comment


                        #12
                        Re: Trouble with ui_bitmap_draw

                        Originally posted by G Gabriel View Post
                        Of course it won't work for you Peter...
                        Ray pointed out my blind spot. Thanks.
                        Peter
                        AlphaBase Solutions, LLC

                        [email protected]
                        https://www.alphabasesolutions.com


                        Comment


                          #13
                          Re: Trouble with ui_bitmap_draw

                          David,

                          Hint: use IMAGE_OPAQUE. This will prevent unhappy flashing when loading or mousing over the dlg.

                          ui_dlg_box("Display Bitmap", <<%dlg%
                          {image_opaque=combine}
                          %dlg%)
                          Peter
                          AlphaBase Solutions, LLC

                          [email protected]
                          https://www.alphabasesolutions.com


                          Comment


                            #14
                            Re: Trouble with ui_bitmap_draw

                            Thanks Peter... the flashing I noted to tackle in a bit... excellent.

                            Comment


                              #15
                              Re: Trouble with ui_bitmap_draw

                              Hi All

                              I want to change the following code I got from the help file to add a jpg image selected by the user and save it in the database. What is does now, is adding a Black bitmap. Any pointers would be appreciated. Also how can one check if a bitmap exists in the adb

                              DIM SHARED vSelectedPic as c
                              DIM SHARED varC_result as C
                              ok_button_label = "&OK"
                              cancel_button_label = "&Cancel"
                              vSelectedPic = ""
                              varC_result = ui_dlg_box("Selected Image",<<%dlg%
                              {region}
                              Chooase An Image:| [%fJPeg (*.jpg)%.40vSelectedPic];
                              {endregion};
                              {line=1,0};
                              {region}
                              <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                              {endregion};
                              %dlg%)
                              'msgbox("The Selected File","Thefilename is "+vSelectedPic)
                              '-----------------------------------
                              IF varC_result = "OK" THEN
                              dim r as C
                              dim g as C
                              dim b as C
                              dim rd as N
                              dim gd as N
                              dim bd as N
                              dim d as P
                              dim dn as C
                              hourglass_cursor(.t.)
                              dn = a5.Get_Name()
                              dn = stritran(dn,".adb",".alb")
                              d = dictionary.open(dn,FILE_RW_EXCLUSIVE)
                              ui_bitmap_create(vSelectedPic, 1.15,1.15)
                              d.enter_begin()
                              d.name = word(file.filename_parse(vSelectedPic,"n"),1,chr(34))
                              d.type = "GBMP"
                              f = d.field_get("contents_m")
                              b1 = ui_bitmap_save(vSelectedPic)
                              f.value_put(b1)
                              d.enter_end(.t.)
                              d.close()
                              hourglass_cursor(.f.)
                              ControlPanel.Refresh()
                              END IF


                              Thanks
                              Peter Gagiano
                              Last edited by gagsoft; June 21, 2009, 12:28 PM.

                              Comment

                              Working...
                              X