COMSafeArray to BinaryData

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2015
Company: emsteknoloji.com

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?

 
#2
People who like this:0Yes/0No
Administrator
Rating: 7
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"?

 
#3
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2015
Company: emsteknoloji.com

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

 
#4
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2015
Company: emsteknoloji.com

Image display failed

 
#5
People who like this:0Yes/0No
Administrator
Rating: 7
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?

 
#6
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2015
Company: emsteknoloji.com

Hi,

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

 
#7
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2015
Company: emsteknoloji.com

How to resize the picture?

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

 
#8
People who like this:0Yes/0No
Administrator
Rating: 7
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.

 
#9
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Aug 11, 2017
Company:

How do I add an add-on?

 
#10
People who like this:0Yes/0No
Administrator
Rating: 7
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/.

 
#11
People who like this:0Yes/0No
Administrator
Rating: 7
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.

 
#12
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jan 17, 2015
Company: emsteknoloji.com

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

 
#13
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Nov 1, 2011
Company:

Вот так надо делать:

ИмяФайла = КаталогВременныхФайлов() + ГУИДСтрока + ".png";
SaveOptionsEnum = Новый Структура("adSaveCreateNotExist, adSaveCreateOverWrite", 1, 2);
ConnectModeEnum = Новый Структура(
       "adModeRead, adModeReadWrite, adModeRecursive, adModeShareDenyNone,
       |adModeShareDenyRead, adModeShareDenyWrite, adModeShareExclusive,
       |adModeUnknown, adModeWrite", 1, 3, 4194304, 16, 4, 8, 12, 0, 2);
StreamTypeEnum = Новый Структура("adTypeBinary, adTypeText", 1, 2);

StreamOut = Новый COMОбъект("ADODB.Stream");
StreamOut.Type = StreamTypeEnum.adTypeBinary;
StreamOut.Mode = ConnectModeEnum.adModeReadWrite;

StreamOut.Open();
StreamOut.Write(ФотоДвоичныеДанные);
StreamOut.SaveToFile(ИмяФайла, SaveOptionsEnum.adSaveCreateOverWrite);
StreamOut.Close();
ФайлФото = Новый ДвоичныеДанные(ИмяФайла);





Base64ДанныеФотографии = Base64Строка(ФайлФото);

 
#14
People who like this:0Yes/0No
Administrator
Rating: 13
Joined: Oct 3, 2019
Company:

Hi Valeriy Martikov,

our forum was created to help developers from other countries work with the 1C platform. The language of communication on our forum is English.

We kindly ask you to duplicate your message in English so that all other participants can understand what you wanted to communicate.


I ask you to treat this requirement with understanding.

 
Subscribe
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.