Loading ...
Sorry, an error occurred while loading the content.

Re: [PowerObject] Convert a blob to an image file.

Expand Messages
  • Barry Johnson
    Try this. It retrieves a jpg stored in an Oracle blob and writes a jpg aphys_id, apub_id are arguments that tell the function what photo blob to retrieve and
    Message 1 of 8 , Sep 19, 2006
    View Source
    • 0 Attachment
      Try this. It retrieves a jpg stored in an Oracle blob and writes a jpg

      aphys_id, apub_id are arguments that tell the function what photo blob to retrieve and what publication the photo is in. Your arguments will be different.

      Note the SELECTBLOB and the loop to assemble the full jpg file from 32765 pieces. Of course the jpg length could be less than 32765, in which case the loop doesn't do much.

      Barry Johnson



      long ll_rows, ll_length, ll_start
      decimal ldec_photo_id
      blob phy_photo, lblob_buf
      int li_write_fnumJPG, li_rtn, li_i, low, high
      string ls_filenameJPG


      low = LowerBound(idec_physPhoto) // array of phys IDs JPGs saved
      high = UpperBound(idec_physPhoto)

      FOR li_i = low TO high
      IF idec_physPhoto[li_i] = aphys_id THEN // already written
      RETURN 1
      END IF
      NEXT

      ll_rows = ids_photo_phy_pub.Retrieve(aphys_id, apub_id) // get the photo_id

      IF ll_rows = 0 THEN
      RETURN 0
      END IF

      IF ll_rows < 0 THEN
      RETURN -1
      END IF

      ldec_photo_id = ids_photo_phy_pub.Object.photo_id[1]

      ls_filenameJPG = 'C:\TEMP\' + String(aphys_id) + '.JPG'
      li_write_fnumJPG = FileOpen(ls_filenameJPG, StreamMode!, Write!, LockWrite!, Replace!)
      IF IsNull(li_write_fnumJPG) or li_write_fnumJPG = -1 THEN
      MessageBox('File Error', 'FileOpen error on ' + ls_filenameJPG + ' failed.')
      RETURN -1
      END IF

      SELECTBLOB PHOTO_IMAGE
      INTO :phy_photo
      FROM "JNOW"."PERSON_PHOTO"
      WHERE "JNOW"."PERSON_PHOTO"."PHOTO_ID" = :ldec_photo_id AND
      "JNOW"."PERSON_PHOTO"."PERSON_ID" = :aphys_id
      USING SQLCA;

      IF SQLCA.SQLCode <> 0 THEN
      MessageBox("Person Photo", "DB Error Code PERSON_PHOTO err in of_write_photo: SQLCode = " +&
      string(SQLCA.SQLCode), StopSign!)
      RETURN -1
      END IF

      IF SQLCA.SQLNRows < 1 THEN
      MessageBox("Person Photo", "DB Error Code PERSON_PHOTO in of_write_photo: SQLNRows = " +&
      string(SQLCA.SQLNRows), StopSign!)
      RETURN -1
      END IF

      IF NOT IsNull(phy_photo) THEN
      ll_length = Len(phy_photo)
      IF ll_length > 0 THEN
      ll_start = 1
      DO
      lblob_buf = BlobMid(phy_photo, ll_start, 32765)
      li_rtn = FileWrite(li_write_fnumJPG, lblob_buf)
      ll_start = ll_start + 32765
      LOOP UNTIL ll_start > ll_length
      li_i = UpperBound(idec_physPhoto) + 1
      idec_physPhoto[li_i] = aphys_ID
      RETURN 1
      END IF
      END IF

      RETURN 0



      ----- Original Message -----
      From: cricketbat4
      To: PowerObject@yahoogroups.com
      Sent: Monday, September 18, 2006 15:24
      Subject: [PowerObject] Convert a blob to an image file.


      Hi all:
      I'm using PB 10.5 with Oracle 9i on a pC tablet. I store a user's
      signature in a blob file type in an Oracle table. I want to retrieve
      this signature stored and convert it to a jpeg file.

      Can someone please tell me how to convert a blob to a jpeg file.

      Thanks in advance.

      Allan.





      [Non-text portions of this message have been removed]
    • Allan DeSouza
      Thanks Barry. I ll try it. Barry Johnson wrote: Try this. It retrieves a jpg stored in an Oracle blob and writes a jpg
      Message 2 of 8 , Sep 19, 2006
      View Source
      • 0 Attachment
        Thanks Barry. I'll try it.

        Barry Johnson <barry.johnson@...> wrote: Try this. It retrieves a jpg stored in an Oracle blob and writes a jpg

        aphys_id, apub_id are arguments that tell the function what photo blob to retrieve and what publication the photo is in. Your arguments will be different.

        Note the SELECTBLOB and the loop to assemble the full jpg file from 32765 pieces. Of course the jpg length could be less than 32765, in which case the loop doesn't do much.

        Barry Johnson

        long ll_rows, ll_length, ll_start
        decimal ldec_photo_id
        blob phy_photo, lblob_buf
        int li_write_fnumJPG, li_rtn, li_i, low, high
        string ls_filenameJPG

        low = LowerBound(idec_physPhoto) // array of phys IDs JPGs saved
        high = UpperBound(idec_physPhoto)

        FOR li_i = low TO high
        IF idec_physPhoto[li_i] = aphys_id THEN // already written
        RETURN 1
        END IF
        NEXT

        ll_rows = ids_photo_phy_pub.Retrieve(aphys_id, apub_id) // get the photo_id

        IF ll_rows = 0 THEN
        RETURN 0
        END IF

        IF ll_rows < 0 THEN
        RETURN -1
        END IF

        ldec_photo_id = ids_photo_phy_pub.Object.photo_id[1]

        ls_filenameJPG = 'C:\TEMP\' + String(aphys_id) + '.JPG'
        li_write_fnumJPG = FileOpen(ls_filenameJPG, StreamMode!, Write!, LockWrite!, Replace!)
        IF IsNull(li_write_fnumJPG) or li_write_fnumJPG = -1 THEN
        MessageBox('File Error', 'FileOpen error on ' + ls_filenameJPG + ' failed.')
        RETURN -1
        END IF

        SELECTBLOB PHOTO_IMAGE
        INTO :phy_photo
        FROM "JNOW"."PERSON_PHOTO"
        WHERE "JNOW"."PERSON_PHOTO"."PHOTO_ID" = :ldec_photo_id AND
        "JNOW"."PERSON_PHOTO"."PERSON_ID" = :aphys_id
        USING SQLCA;

        IF SQLCA.SQLCode <> 0 THEN
        MessageBox("Person Photo", "DB Error Code PERSON_PHOTO err in of_write_photo: SQLCode = " +&
        string(SQLCA.SQLCode), StopSign!)
        RETURN -1
        END IF

        IF SQLCA.SQLNRows < 1 THEN
        MessageBox("Person Photo", "DB Error Code PERSON_PHOTO in of_write_photo: SQLNRows = " +&
        string(SQLCA.SQLNRows), StopSign!)
        RETURN -1
        END IF

        IF NOT IsNull(phy_photo) THEN
        ll_length = Len(phy_photo)
        IF ll_length > 0 THEN
        ll_start = 1
        DO
        lblob_buf = BlobMid(phy_photo, ll_start, 32765)
        li_rtn = FileWrite(li_write_fnumJPG, lblob_buf)
        ll_start = ll_start + 32765
        LOOP UNTIL ll_start > ll_length
        li_i = UpperBound(idec_physPhoto) + 1
        idec_physPhoto[li_i] = aphys_ID
        RETURN 1
        END IF
        END IF

        RETURN 0

        ----- Original Message -----
        From: cricketbat4
        To: PowerObject@yahoogroups.com
        Sent: Monday, September 18, 2006 15:24
        Subject: [PowerObject] Convert a blob to an image file.

        Hi all:
        I'm using PB 10.5 with Oracle 9i on a pC tablet. I store a user's
        signature in a blob file type in an Oracle table. I want to retrieve
        this signature stored and convert it to a jpeg file.

        Can someone please tell me how to convert a blob to a jpeg file.

        Thanks in advance.

        Allan.

        [Non-text portions of this message have been removed]






        ---------------------------------
        Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

        [Non-text portions of this message have been removed]
      • yarevad
        hey Barry, does this code actually work ? If you open a file with replace, how do you append to it in the loop ? When I have done this, I first checked to see
        Message 3 of 8 , Sep 19, 2006
        View Source
        • 0 Attachment
          hey Barry, does this code actually work ? If you open a file with
          replace, how do you append to it in the loop ?

          When I have done this, I first checked to see if the file exists,
          then delete it and do the FileOpen with Append!. If I remember
          correctly, using Replace! caused the file to only contain the last
          write done in the loop.

          Sorry, not trying to be critical, just curious is all.

          Dave

          --- In PowerObject@yahoogroups.com, "Barry Johnson"
          <barry.johnson@...> wrote:
          >
          > Try this. It retrieves a jpg stored in an Oracle blob and writes a
          jpg
          >
          > aphys_id, apub_id are arguments that tell the function what photo
          blob to retrieve and what publication the photo is in. Your
          arguments will be different.
          >
          > Note the SELECTBLOB and the loop to assemble the full jpg file from
          32765 pieces. Of course the jpg length could be less than 32765, in
          which case the loop doesn't do much.
          >
          > Barry Johnson
          >
          >
          >
          > long ll_rows, ll_length, ll_start
          > decimal ldec_photo_id
          > blob phy_photo, lblob_buf
          > int li_write_fnumJPG, li_rtn, li_i, low, high
          > string ls_filenameJPG
          >
          >
          > low = LowerBound(idec_physPhoto) // array of phys IDs JPGs saved
          > high = UpperBound(idec_physPhoto)
          >
          > FOR li_i = low TO high
          > IF idec_physPhoto[li_i] = aphys_id THEN // already written
          > RETURN 1
          > END IF
          > NEXT
          >
          > ll_rows = ids_photo_phy_pub.Retrieve(aphys_id, apub_id) // get the
          photo_id
          >
          > IF ll_rows = 0 THEN
          > RETURN 0
          > END IF
          >
          > IF ll_rows < 0 THEN
          > RETURN -1
          > END IF
          >
          > ldec_photo_id = ids_photo_phy_pub.Object.photo_id[1]
          >
          > ls_filenameJPG = 'C:\TEMP\' + String(aphys_id) + '.JPG'
          > li_write_fnumJPG = FileOpen(ls_filenameJPG, StreamMode!, Write!,
          LockWrite!, Replace!)
          > IF IsNull(li_write_fnumJPG) or li_write_fnumJPG = -1 THEN
          > MessageBox('File Error', 'FileOpen error on ' + ls_filenameJPG + '
          failed.')
          > RETURN -1
          > END IF
          >
          > SELECTBLOB PHOTO_IMAGE
          > INTO :phy_photo
          > FROM "JNOW"."PERSON_PHOTO"
          > WHERE "JNOW"."PERSON_PHOTO"."PHOTO_ID" = :ldec_photo_id AND
          > "JNOW"."PERSON_PHOTO"."PERSON_ID" = :aphys_id
          > USING SQLCA;
          >
          > IF SQLCA.SQLCode <> 0 THEN
          > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO err in
          of_write_photo: SQLCode = " +&
          > string(SQLCA.SQLCode), StopSign!)
          > RETURN -1
          > END IF
          >
          > IF SQLCA.SQLNRows < 1 THEN
          > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO in
          of_write_photo: SQLNRows = " +&
          > string(SQLCA.SQLNRows), StopSign!)
          > RETURN -1
          > END IF
          >
          > IF NOT IsNull(phy_photo) THEN
          > ll_length = Len(phy_photo)
          > IF ll_length > 0 THEN
          > ll_start = 1
          > DO
          > lblob_buf = BlobMid(phy_photo, ll_start, 32765)
          > li_rtn = FileWrite(li_write_fnumJPG, lblob_buf)
          > ll_start = ll_start + 32765
          > LOOP UNTIL ll_start > ll_length
          > li_i = UpperBound(idec_physPhoto) + 1
          > idec_physPhoto[li_i] = aphys_ID
          > RETURN 1
          > END IF
          > END IF
          >
          > RETURN 0
          >
          >
          >
          > ----- Original Message -----
          > From: cricketbat4
          > To: PowerObject@yahoogroups.com
          > Sent: Monday, September 18, 2006 15:24
          > Subject: [PowerObject] Convert a blob to an image file.
          >
          >
          > Hi all:
          > I'm using PB 10.5 with Oracle 9i on a pC tablet. I store a user's
          > signature in a blob file type in an Oracle table. I want to
          retrieve
          > this signature stored and convert it to a jpeg file.
          >
          > Can someone please tell me how to convert a blob to a jpeg file.
          >
          > Thanks in advance.
          >
          > Allan.
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • Barry Johnson
          Yes, it works, but I see what you mean. It must be that PowerBuilder magic. (I didn t write this.) ... From: yarevad To: PowerObject@yahoogroups.com Sent:
          Message 4 of 8 , Sep 19, 2006
          View Source
          • 0 Attachment
            Yes, it works, but I see what you mean. It must be that PowerBuilder magic. (I didn't write this.)

            ----- Original Message -----
            From: yarevad
            To: PowerObject@yahoogroups.com
            Sent: Tuesday, September 19, 2006 11:48
            Subject: [PowerObject] Re: Convert a blob to an image file.


            hey Barry, does this code actually work ? If you open a file with
            replace, how do you append to it in the loop ?

            When I have done this, I first checked to see if the file exists,
            then delete it and do the FileOpen with Append!. If I remember
            correctly, using Replace! caused the file to only contain the last
            write done in the loop.

            Sorry, not trying to be critical, just curious is all.

            Dave

            --- In PowerObject@yahoogroups.com, "Barry Johnson"
            <barry.johnson@...> wrote:
            >
            > Try this. It retrieves a jpg stored in an Oracle blob and writes a
            jpg
            >
            > aphys_id, apub_id are arguments that tell the function what photo
            blob to retrieve and what publication the photo is in. Your
            arguments will be different.
            >
            > Note the SELECTBLOB and the loop to assemble the full jpg file from
            32765 pieces. Of course the jpg length could be less than 32765, in
            which case the loop doesn't do much.
            >
            > Barry Johnson
            >
            >
            >
            > long ll_rows, ll_length, ll_start
            > decimal ldec_photo_id
            > blob phy_photo, lblob_buf
            > int li_write_fnumJPG, li_rtn, li_i, low, high
            > string ls_filenameJPG
            >
            >
            > low = LowerBound(idec_physPhoto) // array of phys IDs JPGs saved
            > high = UpperBound(idec_physPhoto)
            >
            > FOR li_i = low TO high
            > IF idec_physPhoto[li_i] = aphys_id THEN // already written
            > RETURN 1
            > END IF
            > NEXT
            >
            > ll_rows = ids_photo_phy_pub.Retrieve(aphys_id, apub_id) // get the
            photo_id
            >
            > IF ll_rows = 0 THEN
            > RETURN 0
            > END IF
            >
            > IF ll_rows < 0 THEN
            > RETURN -1
            > END IF
            >
            > ldec_photo_id = ids_photo_phy_pub.Object.photo_id[1]
            >
            > ls_filenameJPG = 'C:\TEMP\' + String(aphys_id) + '.JPG'
            > li_write_fnumJPG = FileOpen(ls_filenameJPG, StreamMode!, Write!,
            LockWrite!, Replace!)
            > IF IsNull(li_write_fnumJPG) or li_write_fnumJPG = -1 THEN
            > MessageBox('File Error', 'FileOpen error on ' + ls_filenameJPG + '
            failed.')
            > RETURN -1
            > END IF
            >
            > SELECTBLOB PHOTO_IMAGE
            > INTO :phy_photo
            > FROM "JNOW"."PERSON_PHOTO"
            > WHERE "JNOW"."PERSON_PHOTO"."PHOTO_ID" = :ldec_photo_id AND
            > "JNOW"."PERSON_PHOTO"."PERSON_ID" = :aphys_id
            > USING SQLCA;
            >
            > IF SQLCA.SQLCode <> 0 THEN
            > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO err in
            of_write_photo: SQLCode = " +&
            > string(SQLCA.SQLCode), StopSign!)
            > RETURN -1
            > END IF
            >
            > IF SQLCA.SQLNRows < 1 THEN
            > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO in
            of_write_photo: SQLNRows = " +&
            > string(SQLCA.SQLNRows), StopSign!)
            > RETURN -1
            > END IF
            >
            > IF NOT IsNull(phy_photo) THEN
            > ll_length = Len(phy_photo)
            > IF ll_length > 0 THEN
            > ll_start = 1
            > DO
            > lblob_buf = BlobMid(phy_photo, ll_start, 32765)
            > li_rtn = FileWrite(li_write_fnumJPG, lblob_buf)
            > ll_start = ll_start + 32765
            > LOOP UNTIL ll_start > ll_length
            > li_i = UpperBound(idec_physPhoto) + 1
            > idec_physPhoto[li_i] = aphys_ID
            > RETURN 1
            > END IF
            > END IF
            >
            > RETURN 0
            >
            >
            >
            > ----- Original Message -----
            > From: cricketbat4
            > To: PowerObject@yahoogroups.com
            > Sent: Monday, September 18, 2006 15:24
            > Subject: [PowerObject] Convert a blob to an image file.
            >
            >
            > Hi all:
            > I'm using PB 10.5 with Oracle 9i on a pC tablet. I store a user's
            > signature in a blob file type in an Oracle table. I want to
            retrieve
            > this signature stored and convert it to a jpeg file.
            >
            > Can someone please tell me how to convert a blob to a jpeg file.
            >
            > Thanks in advance.
            >
            > Allan.
            >
            >
            >
            >
            >
            > [Non-text portions of this message have been removed]
            >





            [Non-text portions of this message have been removed]
          • yarevad
            Guess I had one of those DUH moments. Once you open the file, PB doesn t care, it just appends to the file. The replace is only for the open. Dave ...
            Message 5 of 8 , Sep 19, 2006
            View Source
            • 0 Attachment
              Guess I had one of those "DUH" moments. Once you open the file, PB
              doesn't care, it just appends to the file. The replace is only for
              the open.

              Dave

              --- In PowerObject@yahoogroups.com, "Barry Johnson"
              <barry.johnson@...> wrote:
              >
              > Yes, it works, but I see what you mean. It must be that
              PowerBuilder magic. (I didn't write this.)
              >
              > ----- Original Message -----
              > From: yarevad
              > To: PowerObject@yahoogroups.com
              > Sent: Tuesday, September 19, 2006 11:48
              > Subject: [PowerObject] Re: Convert a blob to an image file.
              >
              >
              > hey Barry, does this code actually work ? If you open a file with
              > replace, how do you append to it in the loop ?
              >
              > When I have done this, I first checked to see if the file exists,
              > then delete it and do the FileOpen with Append!. If I remember
              > correctly, using Replace! caused the file to only contain the
              last
              > write done in the loop.
              >
              > Sorry, not trying to be critical, just curious is all.
              >
              > Dave
              >
              > --- In PowerObject@yahoogroups.com, "Barry Johnson"
              > <barry.johnson@> wrote:
              > >
              > > Try this. It retrieves a jpg stored in an Oracle blob and
              writes a
              > jpg
              > >
              > > aphys_id, apub_id are arguments that tell the function what
              photo
              > blob to retrieve and what publication the photo is in. Your
              > arguments will be different.
              > >
              > > Note the SELECTBLOB and the loop to assemble the full jpg file
              from
              > 32765 pieces. Of course the jpg length could be less than 32765,
              in
              > which case the loop doesn't do much.
              > >
              > > Barry Johnson
              > >
              > >
              > >
              > > long ll_rows, ll_length, ll_start
              > > decimal ldec_photo_id
              > > blob phy_photo, lblob_buf
              > > int li_write_fnumJPG, li_rtn, li_i, low, high
              > > string ls_filenameJPG
              > >
              > >
              > > low = LowerBound(idec_physPhoto) // array of phys IDs JPGs saved
              > > high = UpperBound(idec_physPhoto)
              > >
              > > FOR li_i = low TO high
              > > IF idec_physPhoto[li_i] = aphys_id THEN // already written
              > > RETURN 1
              > > END IF
              > > NEXT
              > >
              > > ll_rows = ids_photo_phy_pub.Retrieve(aphys_id, apub_id) // get
              the
              > photo_id
              > >
              > > IF ll_rows = 0 THEN
              > > RETURN 0
              > > END IF
              > >
              > > IF ll_rows < 0 THEN
              > > RETURN -1
              > > END IF
              > >
              > > ldec_photo_id = ids_photo_phy_pub.Object.photo_id[1]
              > >
              > > ls_filenameJPG = 'C:\TEMP\' + String(aphys_id) + '.JPG'
              > > li_write_fnumJPG = FileOpen(ls_filenameJPG, StreamMode!,
              Write!,
              > LockWrite!, Replace!)
              > > IF IsNull(li_write_fnumJPG) or li_write_fnumJPG = -1 THEN
              > > MessageBox('File Error', 'FileOpen error on ' + ls_filenameJPG
              + '
              > failed.')
              > > RETURN -1
              > > END IF
              > >
              > > SELECTBLOB PHOTO_IMAGE
              > > INTO :phy_photo
              > > FROM "JNOW"."PERSON_PHOTO"
              > > WHERE "JNOW"."PERSON_PHOTO"."PHOTO_ID" = :ldec_photo_id AND
              > > "JNOW"."PERSON_PHOTO"."PERSON_ID" = :aphys_id
              > > USING SQLCA;
              > >
              > > IF SQLCA.SQLCode <> 0 THEN
              > > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO err in
              > of_write_photo: SQLCode = " +&
              > > string(SQLCA.SQLCode), StopSign!)
              > > RETURN -1
              > > END IF
              > >
              > > IF SQLCA.SQLNRows < 1 THEN
              > > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO in
              > of_write_photo: SQLNRows = " +&
              > > string(SQLCA.SQLNRows), StopSign!)
              > > RETURN -1
              > > END IF
              > >
              > > IF NOT IsNull(phy_photo) THEN
              > > ll_length = Len(phy_photo)
              > > IF ll_length > 0 THEN
              > > ll_start = 1
              > > DO
              > > lblob_buf = BlobMid(phy_photo, ll_start, 32765)
              > > li_rtn = FileWrite(li_write_fnumJPG, lblob_buf)
              > > ll_start = ll_start + 32765
              > > LOOP UNTIL ll_start > ll_length
              > > li_i = UpperBound(idec_physPhoto) + 1
              > > idec_physPhoto[li_i] = aphys_ID
              > > RETURN 1
              > > END IF
              > > END IF
              > >
              > > RETURN 0
              > >
              > >
              > >
              > > ----- Original Message -----
              > > From: cricketbat4
              > > To: PowerObject@yahoogroups.com
              > > Sent: Monday, September 18, 2006 15:24
              > > Subject: [PowerObject] Convert a blob to an image file.
              > >
              > >
              > > Hi all:
              > > I'm using PB 10.5 with Oracle 9i on a pC tablet. I store a
              user's
              > > signature in a blob file type in an Oracle table. I want to
              > retrieve
              > > this signature stored and convert it to a jpeg file.
              > >
              > > Can someone please tell me how to convert a blob to a jpeg file.
              > >
              > > Thanks in advance.
              > >
              > > Allan.
              > >
              > >
              > >
              > >
              > >
              > > [Non-text portions of this message have been removed]
              > >
              >
              >
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
            • Barry Johnson
              Dave, That explains it. I tried it with append and replace. They give the same results. Anyway, this is a code example that should save people some time.
              Message 6 of 8 , Sep 19, 2006
              View Source
              • 0 Attachment
                Dave,

                That explains it.

                I tried it with append and replace. They give the same results.

                Anyway, this is a code example that should save people some time.

                Barry


                ----- Original Message -----
                From: yarevad
                To: PowerObject@yahoogroups.com
                Sent: Tuesday, September 19, 2006 15:22
                Subject: [PowerObject] Re: Convert a blob to an image file.


                Guess I had one of those "DUH" moments. Once you open the file, PB
                doesn't care, it just appends to the file. The replace is only for
                the open.

                Dave

                --- In PowerObject@yahoogroups.com, "Barry Johnson"
                <barry.johnson@...> wrote:
                >
                > Yes, it works, but I see what you mean. It must be that
                PowerBuilder magic. (I didn't write this.)
                >
                > ----- Original Message -----
                > From: yarevad
                > To: PowerObject@yahoogroups.com
                > Sent: Tuesday, September 19, 2006 11:48
                > Subject: [PowerObject] Re: Convert a blob to an image file.
                >
                >
                > hey Barry, does this code actually work ? If you open a file with
                > replace, how do you append to it in the loop ?
                >
                > When I have done this, I first checked to see if the file exists,
                > then delete it and do the FileOpen with Append!. If I remember
                > correctly, using Replace! caused the file to only contain the
                last
                > write done in the loop.
                >
                > Sorry, not trying to be critical, just curious is all.
                >
                > Dave
                >
                > --- In PowerObject@yahoogroups.com, "Barry Johnson"
                > <barry.johnson@> wrote:
                > >
                > > Try this. It retrieves a jpg stored in an Oracle blob and
                writes a
                > jpg
                > >
                > > aphys_id, apub_id are arguments that tell the function what
                photo
                > blob to retrieve and what publication the photo is in. Your
                > arguments will be different.
                > >
                > > Note the SELECTBLOB and the loop to assemble the full jpg file
                from
                > 32765 pieces. Of course the jpg length could be less than 32765,
                in
                > which case the loop doesn't do much.
                > >
                > > Barry Johnson
                > >
                > >
                > >
                > > long ll_rows, ll_length, ll_start
                > > decimal ldec_photo_id
                > > blob phy_photo, lblob_buf
                > > int li_write_fnumJPG, li_rtn, li_i, low, high
                > > string ls_filenameJPG
                > >
                > >
                > > low = LowerBound(idec_physPhoto) // array of phys IDs JPGs saved
                > > high = UpperBound(idec_physPhoto)
                > >
                > > FOR li_i = low TO high
                > > IF idec_physPhoto[li_i] = aphys_id THEN // already written
                > > RETURN 1
                > > END IF
                > > NEXT
                > >
                > > ll_rows = ids_photo_phy_pub.Retrieve(aphys_id, apub_id) // get
                the
                > photo_id
                > >
                > > IF ll_rows = 0 THEN
                > > RETURN 0
                > > END IF
                > >
                > > IF ll_rows < 0 THEN
                > > RETURN -1
                > > END IF
                > >
                > > ldec_photo_id = ids_photo_phy_pub.Object.photo_id[1]
                > >
                > > ls_filenameJPG = 'C:\TEMP\' + String(aphys_id) + '.JPG'
                > > li_write_fnumJPG = FileOpen(ls_filenameJPG, StreamMode!,
                Write!,
                > LockWrite!, Replace!)
                > > IF IsNull(li_write_fnumJPG) or li_write_fnumJPG = -1 THEN
                > > MessageBox('File Error', 'FileOpen error on ' + ls_filenameJPG
                + '
                > failed.')
                > > RETURN -1
                > > END IF
                > >
                > > SELECTBLOB PHOTO_IMAGE
                > > INTO :phy_photo
                > > FROM "JNOW"."PERSON_PHOTO"
                > > WHERE "JNOW"."PERSON_PHOTO"."PHOTO_ID" = :ldec_photo_id AND
                > > "JNOW"."PERSON_PHOTO"."PERSON_ID" = :aphys_id
                > > USING SQLCA;
                > >
                > > IF SQLCA.SQLCode <> 0 THEN
                > > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO err in
                > of_write_photo: SQLCode = " +&
                > > string(SQLCA.SQLCode), StopSign!)
                > > RETURN -1
                > > END IF
                > >
                > > IF SQLCA.SQLNRows < 1 THEN
                > > MessageBox("Person Photo", "DB Error Code PERSON_PHOTO in
                > of_write_photo: SQLNRows = " +&
                > > string(SQLCA.SQLNRows), StopSign!)
                > > RETURN -1
                > > END IF
                > >
                > > IF NOT IsNull(phy_photo) THEN
                > > ll_length = Len(phy_photo)
                > > IF ll_length > 0 THEN
                > > ll_start = 1
                > > DO
                > > lblob_buf = BlobMid(phy_photo, ll_start, 32765)
                > > li_rtn = FileWrite(li_write_fnumJPG, lblob_buf)
                > > ll_start = ll_start + 32765
                > > LOOP UNTIL ll_start > ll_length
                > > li_i = UpperBound(idec_physPhoto) + 1
                > > idec_physPhoto[li_i] = aphys_ID
                > > RETURN 1
                > > END IF
                > > END IF
                > >
                > > RETURN 0
                > >
                > >
                > >
                > > ----- Original Message -----
                > > From: cricketbat4
                > > To: PowerObject@yahoogroups.com
                > > Sent: Monday, September 18, 2006 15:24
                > > Subject: [PowerObject] Convert a blob to an image file.
                > >
                > >
                > > Hi all:
                > > I'm using PB 10.5 with Oracle 9i on a pC tablet. I store a
                user's
                > > signature in a blob file type in an Oracle table. I want to
                > retrieve
                > > this signature stored and convert it to a jpeg file.
                > >
                > > Can someone please tell me how to convert a blob to a jpeg file.
                > >
                > > Thanks in advance.
                > >
                > > Allan.
                > >
                > >
                > >
                > >
                > >
                > > [Non-text portions of this message have been removed]
                > >
                >
                >
                >
                >
                >
                > [Non-text portions of this message have been removed]
                >





                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.