COMSafeArray to BinaryData



The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jan 17, 2015
Company: EMS TEKNOLOJİ

Hi,
1C Sql I am recording data as an image.
When I read the sql data, it comes as Type COMSafeArray.
How to convert this type to BinaryData?

   Quote selected text in answer   Name
#2
People who like this:0Yes/0No
Administrator
Rating: 8
Joined: Nov 3, 2011
Company: 1C Company

Burak,

can you please describe your scenario in detail, so we can recommend the optimal solution? What is this image for and what do you mean by "1C sql"?

Quote selected text in answer   Name
#3
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jan 17, 2015
Company: EMS TEKNOLOJİ

Hi,



&Atserver
Procedure SAVE_PICTURE()


MyPicture = New BinaryData("C:\Users\Burak\Pictures\images.jpg");


AdoCommand = SQLConnection();
AdoCommand.CommandText ="
|Ins ert mye_ImageData (TableID,RecID_DBCno,RecID_RECno,ImageID,DataID,Data)
|Values (13,0,8,0,'',(SEL ECT CAST('"+ MyPicture +"' AS VARBINARY(MAX))))";

RecordSet = AdoCommand.Execute();

EndProcedure

&Atserver
Procedure SELECT_PICTURE()

AdoCommand = SQLConnection();
AdoCommand.CommandText ="
|SELECT CAST((select Data fr om mye_ImageData Where TableID=13
|and RecID_DBCno=0 and RecID_RECno=8 and ImageID = 0) AS VARCHAR(MAX))";


RecordSet = AdoCommand.Execute();
RecordSet.MoveFirst();

While Not RecordSet.EOF() Do

Value_ = RecordSet.Fields(0).Val ue;

RecordSet.MoveNext();
EndDo;


PictureBinaryData = GetBinaryDataFromString(Value_);


PictureAddress = PutToTempStorage(PictureBinaryData);


EndProcedure

Quote selected text in answer   Name
#4
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jan 17, 2015
Company: EMS TEKNOLOJİ

Image display failed

Quote selected text in answer   Name
#5
People who like this:0Yes/0No
Administrator
Rating: 8
Joined: Nov 3, 2011
Company: 1C Company

Burak,

let's try to localize the error. Please check what you get in this line:

Code
PictureBinaryData = GetBinaryDataFromString(Value_);


If you write this picture to a file, does it look like the original picture? If not, what's the difference from the original picture file?

Quote selected text in answer   Name
#6
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jan 17, 2015
Company: EMS TEKNOLOJİ

Hi,

I used "GetBinaryDataFromBase64String" instead of "GetBinaryDataFromString" , it worked . Thank you.

Quote selected text in answer   Name
#7
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jan 17, 2015
Company: EMS TEKNOLOJİ

How to resize the picture?

For example, C# "Bitmap bmp = new Bitmap (pictureBox1.Image, 500, 700);"

Quote selected text in answer   Name
#8
People who like this:0Yes/0No
Administrator
Rating: 8
Joined: Nov 3, 2011
Company: 1C Company

Burak,

1C:Enteprrise does not provide this functionality. However, you can attach an add-in that resizes pictures.

Quote selected text in answer   Name
#9
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Aug 11, 2017
Company:

How do I add an add-on?

Quote selected text in answer   Name
#10
People who like this:0Yes/0No
Administrator
Rating: 8
Joined: Nov 3, 2011
Company: 1C Company

For information about attaching add-ins, see "Chapter 32. Add-ins" of 1C:Enterprise Developer Guide.

For information about add-in development, see https://1c-dn.com/library/add_in_creation_technology/.

Quote selected text in answer   Name
#11
People who like this:0Yes/0No
Administrator
Rating: 8
Joined: Nov 3, 2011
Company: 1C Company

Maybe the PictureSize property of "form field extension for a picture" will help? If you need to resize a picture solely for displaying it in a form, simply set the form field size and then set PictureSize to Stretch. The picture will exactly fit the form field.

Quote selected text in answer   Name
#12
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jan 17, 2015
Company: EMS TEKNOLOJİ

I made the picture resize with C# and ran RunApp().
Thank you.

Quote selected text in answer   Name
Subscribe
Users browsing this topic (guests: 0, registered: 1, hidden: 0)